コード例 #1
0
ファイル: CalendarDate.java プロジェクト: flovera1/AIWithJava
  /**
   * Returns the time part of the string representation of <code>date</code> adjusted for <code>
   * timezone</code>. The timezone is included in the string if <code>includeTimezoneP</code> is
   * <code>true</code>. The value <code>true</code> is recommended. Milliseconds will be included if
   * <code>includeMillisP</code> is <code>true</code>. Hours will be zero-padded to length 2 if
   * <code>padHoursP</code> is <code>true</code>.
   *
   * @param timezone
   * @param includeTimezoneP
   * @param includeMillisP
   * @param padHoursP
   * @return String
   */
  public String calendarDateToTimeString(
      double timezone, boolean includeTimezoneP, boolean includeMillisP, boolean padHoursP) {
    {
      CalendarDate date = this;

      {
        int hours = Stella.NULL_INTEGER;
        int minutes = Stella.NULL_INTEGER;
        int seconds = Stella.NULL_INTEGER;
        int milli = Stella.NULL_INTEGER;

        {
          Object[] caller_MV_returnarray = new Object[3];

          hours = date.getTime(timezone, caller_MV_returnarray);
          minutes = ((int) (((IntegerWrapper) (caller_MV_returnarray[0])).wrapperValue));
          seconds = ((int) (((IntegerWrapper) (caller_MV_returnarray[1])).wrapperValue));
          milli = ((int) (((IntegerWrapper) (caller_MV_returnarray[2])).wrapperValue));
        }
        {
          String timezoneString =
              (includeTimezoneP
                  ? (((timezone == 0.0) ? " UTC" : (" " + Native.floatToString(timezone))))
                  : "");
          String milliString =
              (includeMillisP
                  ? ("."
                      + Stella.formatWithPadding(
                          Native.integerToString(milli), 3, '0', Stella.KWD_RIGHT, false))
                  : "");

          return (((padHoursP
                  ? Stella.formatWithPadding(
                      Native.integerToString(hours), 2, '0', Stella.KWD_RIGHT, false)
                  : Native.integerToString(hours)))
              + ":"
              + Stella.formatWithPadding(
                  Native.integerToString(minutes), 2, '0', Stella.KWD_RIGHT, false)
              + ":"
              + Stella.formatWithPadding(
                  Native.integerToString(seconds), 2, '0', Stella.KWD_RIGHT, false)
              + milliString
              + timezoneString);
        }
      }
    }
  }
コード例 #2
0
ファイル: CalendarDate.java プロジェクト: flovera1/AIWithJava
  /**
   * Returns the date part of the string representation of <code>date</code> adjusted for <code>
   * timezone</code>. Format is YYYY-MMM-DD, where MMM is a three letter English abbreviation of the
   * month if <code>numericMonthP</code> is <code>false</code> and a two digit numeric value if
   * <code>numericMonthP</code> is <code>true</code>. The value <code>false</code> is recommended.
   *
   * @param timezone
   * @param numericMonthP
   * @return String
   */
  public String calendarDateToDateString(double timezone, boolean numericMonthP) {
    {
      CalendarDate date = this;

      {
        int year = Stella.NULL_INTEGER;
        int month = Stella.NULL_INTEGER;
        int day = Stella.NULL_INTEGER;
        Keyword dow = null;

        {
          Object[] caller_MV_returnarray = new Object[3];

          year = date.getCalendarDate(timezone, caller_MV_returnarray);
          month = ((int) (((IntegerWrapper) (caller_MV_returnarray[0])).wrapperValue));
          day = ((int) (((IntegerWrapper) (caller_MV_returnarray[1])).wrapperValue));
          dow = ((Keyword) (caller_MV_returnarray[2]));
        }
        dow = dow;
        {
          String yearString =
              ((year < 0)
                  ? (Native.integerToString(0 - year) + "BC")
                  : Native.integerToString(year));
          String monthString =
              (numericMonthP
                  ? Stella.formatWithPadding(
                      Native.integerToString(month), 2, '0', Stella.KWD_RIGHT, false)
                  : StringWrapper.unwrapString(
                      ((StringWrapper) ((Stella.$MONTH_ABBREVIATION_VECTOR$.theArray)[month]))));

          return (yearString
              + "-"
              + monthString
              + "-"
              + Stella.formatWithPadding(
                  Native.integerToString(day), 2, '0', Stella.KWD_RIGHT, false));
        }
      }
    }
  }