Package org.joda.time.format

Examples of org.joda.time.format.DateTimeFormatter.parseDateTime()


    public Object fromString(String str) {
        for (int i = 0; i < formattersUTC.length; i++) {
            DateTimeFormatter formatter = formattersUTC[i];
            try {
                DateTime dt = formatter.parseDateTime(str);
                Calendar calendar = dt.toCalendar(Locale.getDefault());
                calendar.setTimeZone(TimeZone.getDefault());
                return calendar;
            } catch (IllegalArgumentException e) {
                // try with next formatter
View Full Code Here


        }
        String timeZoneID = TimeZone.getDefault().getID();
        for (int i = 0; i < formattersNoUTC.length; i++) {
            try {
                DateTimeFormatter formatter = formattersNoUTC[i].withZone(DateTimeZone.forID(timeZoneID));
                DateTime dt = formatter.parseDateTime(str);
                Calendar calendar = dt.toCalendar(Locale.getDefault());
                calendar.setTimeZone(TimeZone.getDefault());
                return calendar;
            } catch (IllegalArgumentException e) {
                // try with next formatter
View Full Code Here

      format = format.withZone(getTimeZone());

      try
      {
        // parse date retaining the time of the submission
        dateTime = format.parseDateTime(value);
      }
      catch (RuntimeException e)
      {
        throw newConversionException(e, locale);
      }
View Full Code Here

    }
    else
    {
      try
      {
        DateTime date = format.parseDateTime(value);
        return date.toDate();
      }
      catch (RuntimeException e)
      {
        throw newConversionException(e, locale);
View Full Code Here

        return handleGet(uriInfo);
    }   
   
    public static Calendar convertTimeStampToCalendar(String timeStamp) throws IllegalArgumentException {
        DateTimeFormatter dateTime = ISODateTimeFormat.dateTimeParser();
        DateTime parsedDateTime = dateTime.parseDateTime(timeStamp);
       
        Calendar result = Calendar.getInstance();
        result.setTimeInMillis(parsedDateTime.getMillis());

        return result;
View Full Code Here

                .withChronology(getChronology(session.getTimeZoneKey()))
                .withOffsetParsed()
                .withLocale(session.getLocale());

        String datetimeString = datetime.toString(Charsets.UTF_8);
        DateTime dateTime = formatter.parseDateTime(datetimeString);
        return DateTimeZoneIndex.packDateTimeWithZone(dateTime);
    }

    @Description("formats the given time by the given format")
    @ScalarFunction
View Full Code Here

  private DateTime convertStringToJodaDateTime(final String theDate) {
    if (StringUtils.isEmpty(theDate)) {
      return null;
    }
    final DateTimeFormatter dateFormat = ISODateTimeFormat.dateTimeNoMillis();
    return new DateTime(dateFormat.parseDateTime(theDate).toDate());
  }
}
View Full Code Here

    @Override
    public void setAsText(String text) {
        if (text != null && !text.isEmpty()) {
          DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(this.format);
          try {
              setValue(dateTimeFormatter.parseDateTime(text));
          } catch (IllegalArgumentException e) {
              setValue(null);
          }
        }
    }
View Full Code Here

      format = format.withZone(getTimeZone());

      try
      {
        // parse date retaining the time of the submission
        dateTime = format.parseDateTime(value);
      }
      catch (RuntimeException e)
      {
        throw new ConversionException(e);
      }
View Full Code Here

    }
    else
    {
      try
      {
        DateTime date = format.parseDateTime(value);
        return date.toDate();
      }
      catch (RuntimeException e)
      {
        throw new ConversionException(e);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.