/** * @param time a time value in milliseconds * @param pattern the formatting pattern to apply * @param precision the precision to apply * @param tz the timezone for the instance * @see Dates#PRECISION_DAY * @see Dates#PRECISION_SECOND */ public Iso8601(final long time, final String pattern, final int precision, java.util.TimeZone tz) { super(Dates.round(time, precision, tz)); //, TimeZone.getTimeZone(TimeZones.GMT_ID))); // format = new SimpleDateFormat(pattern); format = CalendarDateFormatFactory.getInstance(pattern); format.setTimeZone(tz); format.setLenient(CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING)); // use GMT timezone to avoid daylight savings rules affecting floating // time values.. // gmtFormat = new SimpleDateFormat(pattern); // gmtFormat.setTimeZone(TimeZone.getTimeZone(TimeZones.GMT_ID)); this.precision = precision; }
private static java.util.Calendar makeCalendar(boolean lenient, TimeZone timeZone, int year, int month, int day) { return makeCalendar(lenient, timeZone, year, month, day, 0, 0, 0); }
/** * @param time a time value in milliseconds * @param pattern the formatting pattern to apply * @param precision the precision to apply * @param tz the timezone for the instance * @see Dates#PRECISION_DAY * @see Dates#PRECISION_SECOND */ public Iso8601(final long time, final String pattern, final int precision, java.util.TimeZone tz) { super(Dates.round(time, precision, tz)); //, TimeZone.getTimeZone(TimeZones.GMT_ID))); // format = new SimpleDateFormat(pattern); format = CalendarDateFormatFactory.getInstance(pattern); format.setTimeZone(tz); format.setLenient(CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING)); // use GMT timezone to avoid daylight savings rules affecting floating // time values.. // gmtFormat = new SimpleDateFormat(pattern); // gmtFormat.setTimeZone(TimeZone.getTimeZone(TimeZones.GMT_ID)); this.precision = precision; }
private static java.util.Calendar makeCalendar(boolean lenient, TimeZone timeZone, int year, int month, int day) { return makeCalendar(lenient, timeZone, year, month, day, 0, 0, 0); }
/** * @param time a time value in milliseconds * @param pattern the formatting pattern to apply * @param precision the precision to apply * @param tz the timezone for the instance * @see Dates#PRECISION_DAY * @see Dates#PRECISION_SECOND */ public Iso8601(final long time, final String pattern, final int precision, java.util.TimeZone tz) { super(Dates.round(time, precision, tz)); //, TimeZone.getTimeZone(TimeZones.GMT_ID))); // format = new SimpleDateFormat(pattern); format = CalendarDateFormatFactory.getInstance(pattern); format.setTimeZone(tz); format.setLenient(CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING)); // use GMT timezone to avoid daylight savings rules affecting floating // time values.. // gmtFormat = new SimpleDateFormat(pattern); // gmtFormat.setTimeZone(TimeZone.getTimeZone(TimeZones.GMT_ID)); this.precision = precision; }
private static java.util.Calendar makeCalendar(boolean lenient, TimeZone timeZone, int year, int month, int day) { return makeCalendar(lenient, timeZone, year, month, day, 0, 0, 0); }
/** * @param time a time value in milliseconds * @param pattern the formatting pattern to apply * @param precision the precision to apply * @param tz the timezone for the instance * @see Dates#PRECISION_DAY * @see Dates#PRECISION_SECOND */ public Iso8601(final long time, final String pattern, final int precision, java.util.TimeZone tz) { super(Dates.round(time, precision, tz)); //, TimeZone.getTimeZone(TimeZones.GMT_ID))); // format = new SimpleDateFormat(pattern); format = CalendarDateFormatFactory.getInstance(pattern); format.setTimeZone(tz); format.setLenient(CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING)); // use GMT timezone to avoid daylight savings rules affecting floating // time values.. // gmtFormat = new SimpleDateFormat(pattern); // gmtFormat.setTimeZone(TimeZone.getTimeZone(TimeZones.GMT_ID)); this.precision = precision; }
private static java.util.Calendar makeCalendar(boolean lenient, TimeZone timeZone, int year, int month, int day) { return makeCalendar(lenient, timeZone, year, month, day, 0, 0, 0); }
/** * @param time a time value in milliseconds * @param pattern the formatting pattern to apply * @param precision the precision to apply * @param tz the timezone for the instance * @see Dates#PRECISION_DAY * @see Dates#PRECISION_SECOND */ public Iso8601(final long time, final String pattern, final int precision, java.util.TimeZone tz) { super(Dates.round(time, precision, tz)); //, TimeZone.getTimeZone(TimeZones.GMT_ID))); // format = new SimpleDateFormat(pattern); format = CalendarDateFormatFactory.getInstance(pattern); format.setTimeZone(tz); format.setLenient(CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING)); // use GMT timezone to avoid daylight savings rules affecting floating // time values.. // gmtFormat = new SimpleDateFormat(pattern); // gmtFormat.setTimeZone(TimeZone.getTimeZone(TimeZones.GMT_ID)); this.precision = precision; }
private static java.util.Calendar makeCalendar(boolean lenient, TimeZone timeZone, int year, int month, int day) { return makeCalendar(lenient, timeZone, year, month, day, 0, 0, 0); }
private DateFormat getCalendarFormatForPattern(String pattern) { DateFormat cdf = CalendarDateFormatFactory.getInstance(pattern); assertTrue("didn't get calendar format for pattern: " + pattern, cdf.getClass().getName().startsWith(CalendarDateFormatFactory.class.getName())); return cdf; }
public void testFallbackToSimpleDateFormat() throws Exception { SimpleDateFormat f = new SimpleDateFormat("HH"); assertEquals(f, CalendarDateFormatFactory.getInstance("HH")); }
public Object clone() { // don't call super.clone() final CalendarDateFormat f = (CalendarDateFormat) CalendarDateFormatFactory.getInstance(pattern); f.setTimeZone(getTimeZone()); f.setLenient(isLenient()); return f; }
/** * @param value a string representation of a date-time * @param pattern a pattern to apply when parsing the date-time value * @param utc indicates whether the date-time is in UTC time * @throws ParseException where the specified string is not a valid date-time */ public DateTime(String value, String pattern, boolean utc) throws ParseException { this(); final DateFormat format = CalendarDateFormatFactory.getInstance(pattern); if (utc) { setTime(value, format, ((DateFormat) UTC_FORMAT.get()).getTimeZone()); } else { setTime(value, format, null); } setUtc(utc); }
public Object clone() { // don't call super.clone() final CalendarDateFormat f = (CalendarDateFormat) CalendarDateFormatFactory.getInstance(pattern); f.setTimeZone(getTimeZone()); f.setLenient(isLenient()); return f; }
/** * @param value a string representation of a date-time * @param pattern a pattern to apply when parsing the date-time value * @param timezone the timezone for the date-time instance * @throws ParseException where the specified string is not a valid date-time */ public DateTime(String value, String pattern, TimeZone timezone) throws ParseException { // this(); super(Dates.PRECISION_SECOND, timezone != null ? timezone : java.util.TimeZone.getDefault()); this.time = new Time(getTime(), getFormat().getTimeZone()); final DateFormat format = CalendarDateFormatFactory.getInstance(pattern); setTime(value, format, timezone); }
public Object clone() { // don't call super.clone() final CalendarDateFormat f = (CalendarDateFormat) CalendarDateFormatFactory.getInstance(pattern); f.setTimeZone(getTimeZone()); f.setLenient(isLenient()); return f; }
public Object clone() { // don't call super.clone() final CalendarDateFormat f = (CalendarDateFormat) CalendarDateFormatFactory.getInstance(pattern); f.setTimeZone(getTimeZone()); f.setLenient(isLenient()); return f; }
public Object clone() { // don't call super.clone() final CalendarDateFormat f = (CalendarDateFormat) CalendarDateFormatFactory.getInstance(pattern); f.setTimeZone(getTimeZone()); f.setLenient(isLenient()); return f; }
/** * @param value * a string representation of a date-time * @param pattern * a pattern to apply when parsing the date-time value * @param timezone * the timezone for the date-time instance * @throws ParseException * where the specified string is not a valid date-time */ public DateTime(String value, String pattern, TimeZone timezone) throws ParseException { // setting the time to 0 since we are going to reset it anyway super(0, Dates.PRECISION_SECOND, timezone != null ? timezone : java.util.TimeZone.getDefault()); this.time = new Time(getTime(), getFormat().getTimeZone()); final DateFormat format = CalendarDateFormatFactory .getInstance(pattern); setTime(value, format, timezone); }