/** * <p>Formats a {@code Calendar} object.</p> * * @param calendar the calendar to format * @return the formatted string */ @Override public String format(final Calendar calendar) { return printer.format(calendar); }
/** * <p>Formats a millisecond {@code long} value.</p> * * @param millis the millisecond value to format * @return the formatted string * @since 2.1 */ @Override public String format(final long millis) { return printer.format(millis); }
/** * <p>Formats a {@code Date} object using a {@code GregorianCalendar}.</p> * * @param date the date to format * @return the formatted string */ @Override public String format(final Date date) { return printer.format(date); }
/** * <p>Formats a millisecond {@code long} value into the * supplied {@code StringBuffer}.</p> * * @param millis the millisecond value to format * @param buf the buffer to format into * @return the specified string buffer * @since 3.5 */ @Override public <B extends Appendable> B format(final long millis, final B buf) { return printer.format(millis, buf); }
/** * <p>Formats a {@code Calendar} object into the * supplied {@code StringBuffer}.</p> * * @param calendar the calendar to format * @param buf the buffer to format into * @return the specified string buffer * @since 3.5 */ @Override public <B extends Appendable> B format(final Calendar calendar, final B buf) { return printer.format(calendar, buf); }
/** * <p>Formats a {@code Date} object into the * supplied {@code StringBuffer} using a {@code GregorianCalendar}.</p> * * @param date the date to format * @param buf the buffer to format into * @return the specified string buffer * @since 3.5 */ @Override public <B extends Appendable> B format(final Date date, final B buf) { return printer.format(date, buf); }
@Override public StringBuffer format(final Calendar calendar, final StringBuffer buf) { // do not pass in calendar directly, this will cause TimeZone of FastDatePrinter to be ignored return format(calendar.getTime(), buf); }
/** * <p>Formats a {@code Calendar} object into the * supplied {@code StringBuffer}.</p> * * @param calendar the calendar to format * @param buf the buffer to format into * @return the specified string buffer * @deprecated Use {{@link #format(Calendar, Appendable)}. */ @Deprecated @Override public StringBuffer format(final Calendar calendar, final StringBuffer buf) { return printer.format(calendar, buf); }
/** * <p>Formats a {@code Date} object into the * supplied {@code StringBuffer} using a {@code GregorianCalendar}.</p> * * @param date the date to format * @param buf the buffer to format into * @return the specified string buffer * @deprecated Use {{@link #format(Date, Appendable)}. */ @Deprecated @Override public StringBuffer format(final Date date, final StringBuffer buf) { return printer.format(date, buf); }
/** * <p>Formats a {@code Date}, {@code Calendar} or * {@code Long} (milliseconds) object.</p> * This method is an implementation of {@link Format#format(Object, StringBuffer, FieldPosition)} * * @param obj the object to format * @param toAppendTo the buffer to append to * @param pos the position - ignored * @return the buffer passed in */ @Override public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) { return toAppendTo.append(printer.format(obj)); }
/** * <p>Formats a millisecond {@code long} value into the * supplied {@code StringBuffer}.</p> * * @param millis the millisecond value to format * @param buf the buffer to format into * @return the specified string buffer * @since 2.1 * @deprecated Use {{@link #format(long, Appendable)}. */ @Deprecated @Override public StringBuffer format(final long millis, final StringBuffer buf) { return printer.format(millis, buf); }
@Override public String format(final Calendar calendar) { return format(calendar, new StringBuilder(mMaxLengthEstimate)).toString(); }
/** * <p>Formats a {@code Date}, {@code Calendar} or * {@code Long} (milliseconds) object.</p> * @since 3.5 * @param obj the object to format * @return The formatted value. */ String format(final Object obj) { if (obj instanceof Date) { return format((Date) obj); } else if (obj instanceof Calendar) { return format((Calendar) obj); } else if (obj instanceof Long) { return format(((Long) obj).longValue()); } else { throw new IllegalArgumentException("Unknown class: " + (obj == null ? "<null>" : obj.getClass().getName())); } }
/** * <p>Formats a {@code Date}, {@code Calendar} or * {@code Long} (milliseconds) object.</p> * @deprecated Use {{@link #format(Date)}, {{@link #format(Calendar)}, {{@link #format(long)}, or {{@link #format(Object)} * @param obj the object to format * @param toAppendTo the buffer to append to * @param pos the position - ignored * @return the buffer passed in */ @Deprecated @Override public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) { if (obj instanceof Date) { return format((Date) obj, toAppendTo); } else if (obj instanceof Calendar) { return format((Calendar) obj, toAppendTo); } else if (obj instanceof Long) { return format(((Long) obj).longValue(), toAppendTo); } else { throw new IllegalArgumentException("Unknown class: " + (obj == null ? "<null>" : obj.getClass().getName())); } }
@Test public void testPrinter() { final FastDatePrinter printer = new FastDatePrinter("YYYY-'W'ww-u", TimeZone.getDefault(), Locale.getDefault()); vulgar.setMinimalDaysInFirstWeek(4); vulgar.setFirstDayOfWeek(Calendar.MONDAY); assertEquals(isoForm, printer.format(vulgar)); } }
/** * <p>Formats a millisecond {@code long} value.</p> * * @param millis the millisecond value to format * @return the formatted string * @since 2.1 */ @Override public String format(final long millis) { return printer.format(millis); }
/** * <p>Formats a {@code Calendar} object.</p> * * @param calendar the calendar to format * @return the formatted string */ @Override public String format(final Calendar calendar) { return printer.format(calendar); }
/** * <p>Formats a {@code Calendar} object.</p> * * @param calendar the calendar to format * @return the formatted string */ @Override public String format(final Calendar calendar) { return printer.format(calendar); }
/** * <p>Formats a {@code Date} object using a {@code GregorianCalendar}.</p> * * @param date the date to format * @return the formatted string */ @Override public String format(final Date date) { return printer.format(date); }
@Override public StringBuffer format(final Calendar calendar, final StringBuffer buf) { // do not pass in calendar directly, this will cause TimeZone of FastDatePrinter to be ignored return format(calendar.getTime(), buf); }