Package org.joda.time.format

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


  String toString(final Object source)
  {
    final DateTime data = (DateTime) source;
    final DateTimeFormatter printFormat = DateTimeFormat.forPattern(ISO_FORMAT);
    final String date = printFormat.withZone(DateTimeZone.UTC).print(data);
    return date;
  }

  @Override
  public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context)
View Full Code Here


  Object parse(final String data)
  {
    try {
      final DateTimeFormatter parseFormat = DateTimeFormat.forPattern(ISO_FORMAT);
      final DateTime date = parseFormat.withZone(DateTimeZone.UTC).parseDateTime(data);
      final DateTimeZone dateTimeZone = PFUserContext.getDateTimeZone();
      return new DateTime(date, dateTimeZone);
    } catch (final Exception ex) {
      log.error("Can't parse DateMidnight: " + data);
      return new DateMidnight();
View Full Code Here

    // 按不同的时区分析字符串,得到不同的时间
    String dateString = "1978-06-01 12:10:08";
    DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");

    DateTime parserResult1 = fmt.withZone(DateTimeZone.forID("US/Pacific")).parseDateTime(dateString);
    DateTime parserResult2 = fmt.withZoneUTC().parseDateTime(dateString);

    System.out.println(parserResult1.toString(format) + " " + parserResult1.getMillis());
    System.out.println(parserResult2.toString(format) + " " + parserResult2.getMillis());
  }
View Full Code Here

        else fmt = DateTimeFormat.fullDateTime();

        fmt = fmt.withLocale(locale);
        if (null != timezone) {
            DateTimeZone dtz = DateTimeZone.forID(timezone);
            fmt = fmt.withZone(dtz);
        }
        return fmt.print((DateTime)val);
    }
}
View Full Code Here

    private DateTimeFormatter getDateTimeFormatter(SerializerProvider provider)
    {
        DateTimeFormatter formatter = defaultFormat;
        TimeZone ts = provider.getTimeZone();
        if (ts != null) {
            formatter = formatter.withZone(DateTimeZone.forTimeZone(ts));
        }
        return formatter;
    }
}
View Full Code Here

    {
      TimeZone zone = getClientTimeZone();
      if (zone != null)
      {
        // apply time zone to formatter
        format = format.withZone(DateTimeZone.forTimeZone(zone));
      }
    }
    return format.print(dt);
  }
View Full Code Here

      // instantiate now/ current time
      MutableDateTime dt = new MutableDateTime();
      if (zone != null)
      {
        // set time zone for client
        format = format.withZone(DateTimeZone.forTimeZone(zone));
        dt.setZone(DateTimeZone.forTimeZone(zone));
      }
      // parse date retaining the time of the submission
      format.parseInto(dt, value, 0);
      // apply the server time zone to the parsed value
View Full Code Here

      // instantiate now/ current time
      MutableDateTime dt = new MutableDateTime(new DateMidnight());
      if (zone != null)
      {
        // set time zone for client
        format = format.withZone(DateTimeZone.forTimeZone(zone));
        dt.setZone(DateTimeZone.forTimeZone(zone));
      }
      try
      {
        // parse date retaining the time of the submission
View Full Code Here

    {
      TimeZone zone = getClientTimeZone();
      if (zone != null)
      {
        // apply time zone to formatter
        format = format.withZone(DateTimeZone.forTimeZone(zone));
      }
    }
    return format.print(dt);
  }
View Full Code Here

            return null;
        }

        DateTimeFormatter parser = dateTimeFormatter.parser();
        if (timeZone != null) {
            parser = parser.withZone(timeZone);
        }
        return parser;
    }

    private long parseStringValue(String value, DateTimeZone timeZone) {
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.