Package org.joda.time.format

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


      dt.setZone(getTimeZone());
      return dt.toDate();
    }
    else
    {
      return format.parseDateTime(value).toDate();
    }
  }

  /**
   * @see org.apache.wicket.util.convert.IConverter#convertToString(java.lang.Object,
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

    Object constant = node.getState();
    if (info.isJodaType()) {
      DateTimeFormatter fmt;
      if (info.getClassType().getName().equals("org.joda.time.DateTime")) {
        fmt = ISODateTimeFormat.dateTime();
        DateTime dateTime = fmt.parseDateTime(constant.toString());
        return StandardConverters.convertToBytes(dateTime);
      } else if (info.getClassType().getName().equals("org.joda.time.LocalDateTime")) {
        fmt = ISODateTimeFormat.dateTime();
        LocalDateTime localDateTime = fmt.parseLocalDateTime(constant.toString());
        return StandardConverters.convertToBytes(localDateTime);
View Full Code Here

        // See http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html
        DateTimeFormatter parser = DateTimeFormat.forPattern(format);
        DateTime result;
        try {
            result = parser.parseDateTime(date);
        } catch(Exception e) {
            return null;
        }

        return result.toString();
View Full Code Here

        //DateTimeZone dtz = extractDateTimeZone(dtStr);
        //The timezone in the customized format is not predictable
        DateTimeFormatter dtf = DateTimeFormat.forPattern(DataType
                .toString(input.get(1)));
        //if (dtz == null) {
            return dtf.parseDateTime(dtStr);
        //} else {
        //    return dtf.withZone(dtz).parseDateTime(dtStr);
        //}
    }
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 ModelUtil() {}

    public static Date stringToDate(String dateString){
        DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis();
        return fmt.parseDateTime(dateString).toDate();
    }

    public static String dateToString(Date date){
        DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis();
        DateTime dateTime = new DateTime(date);
View Full Code Here

        //DateTimeZone dtz = extractDateTimeZone(dtStr);
        //The timezone in the customized format is not predictable
        DateTimeFormatter dtf = DateTimeFormat.forPattern(DataType
                .toString(input.get(1)));
        //if (dtz == null) {
            return dtf.parseDateTime(dtStr);
        //} else {
        //    return dtf.withZone(dtz).parseDateTime(dtStr);
        //}
    }
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.