Top Description Methods
org.apache.commons.lang3.time

public Interface DatePrinter

Known Direct Implementers
org.apache.commons.lang3.time.FastDateFormat, org.apache.commons.lang3.time.FastDatePrinter
Imports
java.text.FieldPosition, java.util.Calendar, .Date, .GregorianCalendar, .Locale, .TimeZone

DatePrinter is the "missing" interface for the format methods of java.text.DateFormat. You can obtain an object implementing this interface by using one of the FastDateFormat factory methods.

Warning

Since binary compatible methods may be added to this interface in any release, developers are not expected to implement this interface.

Since
3.2

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the formatted string.
format
(Calendar
the calendar to format.
calendar
)

Formats a Calendar object.

public <
the Appendable class type, usually StringBuilder or StringBuffer.
B extends Appendable
>
B

Returns:

the specified string buffer.
format
(Calendar
the calendar to format.
calendar
,
B
the buffer to format into.
buf
)

Formats a Calendar object into the supplied Appendable.

public StringBuffer

Returns:

the specified string buffer.
format
(Calendar
the calendar to format.
calendar
,
StringBuffer
the buffer to format into.
buf
)
Deprecated Use {format(Calendar, Appendable).

Formats a Calendar object into the supplied StringBuffer.

public String

Returns:

the formatted string
format
(Date
the date to format
date
)

Formats a Date object using a GregorianCalendar.

public <
the Appendable class type, usually StringBuilder or StringBuffer.
B extends Appendable
>
B

Returns:

the specified string buffer.
format
(Date
the date to format.
date
,
B
the buffer to format into.
buf
)

Formats a Date object into the supplied Appendable using a GregorianCalendar.

public StringBuffer

Returns:

the specified string buffer.
format
(Date
the date to format.
date
,
StringBuffer
the buffer to format into.
buf
)
Deprecated Use {format(Date, Appendable).

Formats a Date object into the supplied StringBuffer using a GregorianCalendar.

public String

Returns:

the formatted string.
format
(long
the millisecond value to format.
millis
)

Formats a millisecond long value.

public <
the Appendable class type, usually StringBuilder or StringBuffer.
B extends Appendable
>
B

Returns:

the specified string buffer.
format
(long
the millisecond value to format.
millis
,
B
the buffer to format into.
buf
)

Formats a millisecond long value into the supplied Appendable.

public StringBuffer

Returns:

the specified string buffer.
format
(long
the millisecond value to format.
millis
,
StringBuffer
the buffer to format into.
buf
)
Deprecated Use {format(long, Appendable).

Formats a millisecond long value into the supplied StringBuffer.

public StringBuffer

Returns:

the buffer passed in.
format
(Object
the object to format.
obj
,
StringBuffer
the buffer to append to.
toAppendTo
,
FieldPosition
the position - ignored.
pos
)

Formats a Date, Calendar or Long (milliseconds) object.

public Locale

Returns:

the locale.
getLocale
()

Gets the locale used by this printer.

public String

Returns:

the pattern, java.text.SimpleDateFormat compatible.
getPattern
()

Gets the pattern used by this printer.

public TimeZone

Returns:

the time zone.
getTimeZone
()

Gets the time zone used by this printer.

Method Detail

formatback to summary
public String format(Calendar calendar)

Formats a Calendar object. The TimeZone set on the Calendar is only used to adjust the time offset. The TimeZone specified during the construction of the Parser will determine the TimeZone used in the formatted string.

Parameters
calendar:Calendar

the calendar to format.

Returns:String

the formatted string.

formatback to summary
public <B extends Appendable> B format(Calendar calendar, B buf)

Formats a Calendar object into the supplied Appendable. The TimeZone set on the Calendar is only used to adjust the time offset. The TimeZone specified during the construction of the Parser will determine the TimeZone used in the formatted string.

Parameters
<B>
the Appendable class type, usually StringBuilder or StringBuffer.
calendar:Calendar

the calendar to format.

buf:B

the buffer to format into.

Returns:B

the specified string buffer.

Since
3.5
formatback to summary
public StringBuffer format(Calendar calendar, StringBuffer buf)

Formats a Calendar object into the supplied StringBuffer. The TimeZone set on the Calendar is only used to adjust the time offset. The TimeZone specified during the construction of the Parser will determine the TimeZone used in the formatted string.

Parameters
calendar:Calendar

the calendar to format.

buf:StringBuffer

the buffer to format into.

Returns:StringBuffer

the specified string buffer.

Annotations
@Deprecated
formatback to summary
public String format(Date date)

Formats a Date object using a GregorianCalendar.

Parameters
date:Date

the date to format

Returns:String

the formatted string

formatback to summary
public <B extends Appendable> B format(Date date, B buf)

Formats a Date object into the supplied Appendable using a GregorianCalendar.

Parameters
<B>
the Appendable class type, usually StringBuilder or StringBuffer.
date:Date

the date to format.

buf:B

the buffer to format into.

Returns:B

the specified string buffer.

Since
3.5
formatback to summary
public StringBuffer format(Date date, StringBuffer buf)

Deprecated

Use {format(Date, Appendable).

Formats a Date object into the supplied StringBuffer using a GregorianCalendar.

Parameters
date:Date

the date to format.

buf:StringBuffer

the buffer to format into.

Returns:StringBuffer

the specified string buffer.

Annotations
@Deprecated
formatback to summary
public String format(long millis)

Formats a millisecond long value.

Parameters
millis:long

the millisecond value to format.

Returns:String

the formatted string.

Since
2.1
formatback to summary
public <B extends Appendable> B format(long millis, B buf)

Formats a millisecond long value into the supplied Appendable.

Parameters
<B>
the Appendable class type, usually StringBuilder or StringBuffer.
millis:long

the millisecond value to format.

buf:B

the buffer to format into.

Returns:B

the specified string buffer.

Since
3.5
formatback to summary
public StringBuffer format(long millis, StringBuffer buf)

Deprecated

Use {format(long, Appendable).

Formats a millisecond long value into the supplied StringBuffer.

Parameters
millis:long

the millisecond value to format.

buf:StringBuffer

the buffer to format into.

Returns:StringBuffer

the specified string buffer.

Annotations
@Deprecated
formatback to summary
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)

Formats a Date, Calendar or Long (milliseconds) object.

Parameters
obj:Object

the object to format.

toAppendTo:StringBuffer

the buffer to append to.

pos:FieldPosition

the position - ignored.

Returns:StringBuffer

the buffer passed in.

See Also
java.text.DateFormat#format(Object, StringBuffer, FieldPosition)
getLocaleback to summary
public Locale getLocale()

Gets the locale used by this printer.

Returns:Locale

the locale.

getPatternback to summary
public String getPattern()

Gets the pattern used by this printer.

Returns:String

the pattern, java.text.SimpleDateFormat compatible.

getTimeZoneback to summary
public TimeZone getTimeZone()

Gets the time zone used by this printer.

This zone is always used for Date printing.

Returns:TimeZone

the time zone.