panda.lang.time.DatePrinter Maven / Gradle / Ivy
Show all versions of panda-core Show documentation
package panda.lang.time;
import java.text.FieldPosition;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
/**
*
* DatePrinter is the "missing" interface for the format methods of {@link java.text.DateFormat}.
*
*/
public interface DatePrinter {
/**
*
* Formats a millisecond {@code long} value.
*
*
* @param millis the millisecond value to format
* @return the formatted string
*/
String format(long millis);
/**
*
* Formats a {@code Date} object using a {@code GregorianCalendar}.
*
*
* @param date the date to format
* @return the formatted string
*/
String format(Date date);
/**
*
* Formats a {@code Calendar} object.
*
*
* @param calendar the calendar to format
* @return the formatted string
*/
String format(Calendar calendar);
/**
*
* Formats a milliseond {@code long} value into the supplied {@code StringBuilder}.
*
*
* @param millis the millisecond value to format
* @param buf the buffer to format into
* @return the specified string buffer
*/
B format(long millis, B buf);
/**
*
* Formats a {@code Date} object into the supplied {@code StringBuilder} using a
* {@code GregorianCalendar}.
*
*
* @param date the date to format
* @param buf the buffer to format into
* @return the specified string buffer
*/
B format(Date date, B buf);
/**
*
* Formats a {@code Calendar} object into the supplied {@code StringBuilder}.
*
*
* @param calendar the calendar to format
* @param buf the buffer to format into
* @return the specified string buffer
*/
B format(Calendar calendar, B buf);
// Accessors
// -----------------------------------------------------------------------
/**
*
* Gets the pattern used by this printer.
*
*
* @return the pattern, {@link java.text.SimpleDateFormat} compatible
*/
String getPattern();
/**
*
* Gets the time zone used by this printer.
*
*
* This zone is always used for {@code Date} printing.
*
*
* @return the time zone
*/
TimeZone getTimeZone();
/**
*
* Gets the locale used by this printer.
*
*
* @return the locale
*/
Locale getLocale();
/**
*
* Formats a {@code Date}, {@code Calendar} or {@code Long} (milliseconds) object.
*
*
* @param obj the object to format
* @param toAppendTo the buffer to append to
* @param pos the position - ignored
* @return the buffer passed in
*/
StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos);
}