Package org.joda.time.format

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


        String date = input.get(0).toString();
        String format = input.get(1).toString();

        // See http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html
        DateTimeFormatter parser = DateTimeFormat.forPattern(format);
        DateTime result = parser.parseDateTime(date);

        return result.toString();
    }

  @Override
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


  private void verifyFormat(String x, String format, DateTime dateTime) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern(format);
    assertThat(formatter.print(dateTime), equalTo(x));
    assertThat(formatter.parseDateTime(x), equalTo(dateTime));
  }
 
}
View Full Code Here

        }
        final String timeZoneID = TimeZone.getDefault().getID();
        for (final DateTimeFormatter element : formattersNoUTC) {
            try {
                final DateTimeFormatter formatter = element.withZone(DateTimeZone.forID(timeZoneID));
                final DateTime dt = formatter.parseDateTime(str);
                final Calendar calendar = dt.toGregorianCalendar();
                calendar.setTimeZone(TimeZone.getDefault());
                return calendar;
            } catch (final IllegalArgumentException e) {
                // try with next formatter
View Full Code Here

            DateTime dt = null;
            String text = getLabelElement().getText();
            String timeStamp = text.substring(text.indexOf('[') + 1, text.indexOf(']'));
            DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:m:s.S");
            try {
                dt = formatter.parseDateTime(timeStamp);
            } catch (IllegalArgumentException e) {
                throw new RuntimeException("Something went wrong with parsing of log entry timestamp!", e);
            }
            return dt;
        }
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

    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

    }
    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.