On this page

DatePrinter

public interface org.apache.commons.lang3.time.DatePrinter[source]

DatePrinter is the "missing" interface for the format methods of 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

Methods

StringBuffer

format(Object obj, StringBuffer toAppendTo, FieldPosition pos)

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

String

format(Calendar calendar)

Formats a Calendar object.

<B extends Appendable> B

format(Calendar calendar, B buf)

Formats a Calendar object into the supplied Appendable.

StringBuffer

format(Calendar calendar, StringBuffer buf)

Deprecated. Formats a Calendar object into the supplied StringBuffer.

String

format(Date date)

Formats a Date object using a GregorianCalendar.

<B extends Appendable> B

format(Date date, B buf)

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

StringBuffer

format(Date date, StringBuffer buf)

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

String

format(long millis)

Formats a millisecond long value.

<B extends Appendable> B

format(long millis, B buf)

Formats a millisecond long value into the supplied Appendable.

StringBuffer

format(long millis, StringBuffer buf)

Deprecated. Formats a millisecond long value into the supplied StringBuffer.

Locale

getLocale()

Gets the locale used by this printer.

String

getPattern()

Gets the pattern used by this printer.

TimeZone

getTimeZone()

Gets the time zone used by this printer.

StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)[source]

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

Parameters:
  • obj – The object to format.

  • toAppendTo – The buffer to append to.

  • pos – The position - ignored.

Returns:

The buffer passed in.

See also:

DateFormat.format(Object, StringBuffer, FieldPosition)

String format(Calendar calendar)[source]

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 – The calendar to format.

Returns:

The formatted string.

<B extends Appendable> B format(Calendar calendar, B buf)[source]

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.

Type parameters:

<B> – The Appendable class type, usually StringBuilder or StringBuffer.

Parameters:
  • calendar – The calendar to format.

  • buf – The buffer to format into.

Returns:

The specified string buffer.

Since:

3.5

@Deprecated StringBuffer format(Calendar calendar, StringBuffer buf)[source]

Deprecated: Use {format(Calendar, Appendable).

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 – The calendar to format.

  • buf – The buffer to format into.

Returns:

The specified string buffer.

String format(Date date)[source]

Formats a Date object using a GregorianCalendar.

Parameters:

date – The date to format

Returns:

The formatted string

<B extends Appendable> B format(Date date, B buf)[source]

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

Type parameters:

<B> – The Appendable class type, usually StringBuilder or StringBuffer.

Parameters:
  • date – The date to format.

  • buf – The buffer to format into.

Returns:

The specified string buffer.

Since:

3.5

@Deprecated StringBuffer format(Date date, StringBuffer buf)[source]

Deprecated: Use {format(Date, Appendable).

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

Parameters:
  • date – The date to format.

  • buf – The buffer to format into.

Returns:

The specified string buffer.

String format(long millis)[source]

Formats a millisecond long value.

Parameters:

millis – The millisecond value to format.

Returns:

The formatted string.

Since:

2.1

<B extends Appendable> B format(long millis, B buf)[source]

Formats a millisecond long value into the supplied Appendable.

Type parameters:

<B> – The Appendable class type, usually StringBuilder or StringBuffer.

Parameters:
  • millis – The millisecond value to format.

  • buf – The buffer to format into.

Returns:

The specified string buffer.

Since:

3.5

@Deprecated StringBuffer format(long millis, StringBuffer buf)[source]

Deprecated: Use {format(long, Appendable).

Formats a millisecond long value into the supplied StringBuffer.

Parameters:
  • millis – The millisecond value to format.

  • buf – The buffer to format into.

Returns:

The specified string buffer.

Locale getLocale()[source]

Gets the locale used by this printer.

Returns:

The locale.

String getPattern()[source]

Gets the pattern used by this printer.

Returns:

The pattern, SimpleDateFormat compatible.

TimeZone getTimeZone()[source]

Gets the time zone used by this printer.

This zone is always used for Date printing.

Returns:

The time zone.