示例#1
0
  /**
   * Returns a calendar date object representing the date and time parsed from the <code>input
   * </code> string. If no valid parse is found, <code>null</code> is returned.
   *
   * @param input
   * @return CalendarDate
   */
  public static CalendarDate stringToCalendarDate(String input) {
    {
      DecodedDateTime dateTime =
          DecodedDateTime.parseDateTimeInTimeZone(
              input, Stella.NULL_FLOAT, 0, Stella.NULL_INTEGER, false);

      if (dateTime == null) {
        return (null);
      } else {
        return (dateTime.encodeCalendarDate());
      }
    }
  }
示例#2
0
  /**
   * Returns a calendar date object representing the date and time parsed from the <code>inputDate
   * </code> string. Default values for missing fields and the interpretation of relative references
   * come from <code>defaultDate</code>. If the <code>defaultDate</code> is <code>null</code>, the
   * current date will be used. If a null set of defaults is desired, use <code>
   * $NULL_DECODED_DATE_TIME$</code>. If no valid parse is found, <code>null</code> is returned.
   *
   * @param inputDate
   * @param defaultDate
   * @return CalendarDate
   */
  public static CalendarDate stringToCalendarDateWithDefault(
      String inputDate, DecodedDateTime defaultDate) {
    if (defaultDate == null) {
      return (CalendarDate.stringToCalendarDate(inputDate));
    } else {
      {
        DecodedDateTime dateTime =
            DecodedDateTime.parseDateTimeRelativeToBase(
                inputDate, defaultDate, 0, Stella.NULL_INTEGER, false, true);

        if (dateTime == null) {
          return (null);
        } else {
          return (dateTime.encodeCalendarDate());
        }
      }
    }
  }