org.enblom.time
Interface TimeFormatter


public interface TimeFormatter

Provides methods for formatting a Time object as a human-readable string.

The following notation will be used:

YYYY:The year written with four digits, e.g. 1066, 1969, 2011
YY:The year written with two digits, e.g. 66, 69, 11
MM:The month written with two digits, e.g. 02 for February and 10 for October
DD:The day of the month written with two digits, e.g. 02, 15, 31
hh:The hour of the time written with two digits. A 24-hour scale is used, so this will be in the range 00-23.
mm:The minute of the time written with two digits; in the range 00-59.
ss:The second of the time written with two digits; in the range 00-59.
nnn:The millisecond of the time written with three digits; in the range 000-999.

There are three standard formatters: ISO, EUR and US, provided by Time.iso(), Time.eur() and Time.us(), respectively. The ISO formatter formats timestamps according to the ISO-8601 standard, the EUR formatter formats timestamps according to some de-facto European standard, and the US formatter formats timestamps according to US standards. The main difference between these formatters is how dates are formatted:

ISO:YYYY-MM-DD, YYYYMMDD
EUR:DD.MM.YYYY, DDMMYYYY
US:MM/DD/YYYY, MMDDYYYY

Author:
Andreas Enblom

Method Summary
 String formatCompactDate()
          Formats the date of the time as a compact string, with no delimiters between year, month and date.
 String formatCompactLongTime()
          Formats the time of day of this time as a compact string, with no delimiters between the different parts of this time.
 String formatCompactShortDate()
          Formats the date of the time as a compact string, with no delimiters between year, month and date.
 String formatCompactShortDateAndLongTime()
          Formats the the time as a full string.
 String formatCompactShortDateAndShortTime()
          Formats the the time as a full string.
 String formatCompactShortDateAndTime()
          Formats the the time as a full string.
 String formatCompactShortTime()
          Formats the time of day of this time as a compact string, with no delimiters between the different parts of this time.
 String formatCompactTime()
          Formats the time of day of this time as a compact string, with no delimiters between the different parts of this time.
 String formatDate()
          Formats the date of this time as a string, with delimiters between year, month and day.
 String formatDateAndLongTime()
          Formats the the time as a full string.
 String formatDateAndShortTime()
          Formats the the time as a full string.
 String formatDateAndTime()
          Formats the the time as a full string.
 String formatLongTime()
          Formats the time of day of the time as a string, with delimiters between the different parts of this time.
 String formatShortDate()
          Formats the date of this time as a string, with delimiters between year, month and day.
 String formatShortDateAndLongTime()
          Formats the the time as a full string.
 String formatShortDateAndShortTime()
          Formats the the time as a full string.
 String formatShortDateAndTime()
          Formats the the time as a full string.
 String formatShortTime()
          Formats the time of day of the time as a string, with delimiters between the different parts of this time.
 String formatTime()
          Formats the time of day of the time as a string, with delimiters between the different parts of this time.
 

Method Detail

formatDate

String formatDate()
Formats the date of this time as a string, with delimiters between year, month and day. The year is written with four digits.
FormatterFormat
ISOYYYY-MM-DD
EURDD.MM.YYYY
USMM/DD/YYYY

Returns:
The date of this time, formatted as a string.

formatShortDate

String formatShortDate()
Formats the date of this time as a string, with delimiters between year, month and day. The year is written with two digits.
FormatterFormat
ISOYY-MM-DD
EURDD.MM.YY
USMM/DD/YY

Returns:
The date of the time, formatted as a string.

formatCompactDate

String formatCompactDate()
Formats the date of the time as a compact string, with no delimiters between year, month and date. The year is written with four digits.
FormatterFormat
ISOYYYYMMDD
EURDDMMYYYY
USMMDDYYYY

Returns:
The date of this time, formatted as a string.

formatCompactShortDate

String formatCompactShortDate()
Formats the date of the time as a compact string, with no delimiters between year, month and date. The year is written with two digits.
FormatterFormat
ISOYYMMDD
EURDDMMYY
USMMDDYY

Returns:
The date of this time, formatted as a string.

formatTime

String formatTime()
Formats the time of day of the time as a string, with delimiters between the different parts of this time. The formatting will include hour, minute and second.
FormatterFormat
ISOhh:mm:ss
EURhh:mm:ss
UShh:mm:ss

Returns:
The time of day of the time, formatted as a string.

formatLongTime

String formatLongTime()
Formats the time of day of the time as a string, with delimiters between the different parts of this time. The formatting will include hour, minute, second and millisecond.
FormatterFormat
ISOhh:mm:ss.nnn
EURhh:mm:ss.nnn
UShh:mm:ss.nnn

Returns:
The time of day of the time, formatted as a string.

formatShortTime

String formatShortTime()
Formats the time of day of the time as a string, with delimiters between the different parts of this time. The formatting will include hour and minute.
FormatterFormat
ISOhh:mm
EURhh:mm
UShh:mm

Returns:
The time of day of the time, formatted as a string.

formatCompactTime

String formatCompactTime()
Formats the time of day of this time as a compact string, with no delimiters between the different parts of this time. The formatting will include hour, minute and second.
FormatterFormat
ISOhhmmss
EURhhmmss
UShhmmss

Returns:
The time of day of this time, formatted as a string.

formatCompactLongTime

String formatCompactLongTime()
Formats the time of day of this time as a compact string, with no delimiters between the different parts of this time. The formatting will include hour, minute, second and millisecond.
FormatterFormat
ISOhhmmssnnn
EURhhmmssnnn
UShhmmssnnn

Returns:
The time of day of this time, formatted as a string.

formatCompactShortTime

String formatCompactShortTime()
Formats the time of day of this time as a compact string, with no delimiters between the different parts of this time. The formatting will include hour and minute.
FormatterFormat
ISOhhmm
EURhhmm
UShhmm

Returns:
The time of day of this time, formatted as a string.

formatDateAndTime

String formatDateAndTime()
Formats the the time as a full string. The year is written with four digits, and the time of day will include hour, minute and second.
FormatterFormat
ISOYYYY-MM-DD hh:mm:ss
EURDD.MM.YYYY hh:mm:ss
USMM/DD/YYYY hh:mm:ss

Returns:
The time, formatted as an full string.

formatDateAndLongTime

String formatDateAndLongTime()
Formats the the time as a full string. The year is written with four digits, and the time of day will include hour, minute, second and millisecond.
FormatterFormat
ISOYYYY-MM-DD hh:mm:ss.nnn
EURDD.MM.YYYY hh:mm:ss.nnn
USMM/DD/YYYY hh:mm:ss.nnn

Returns:
The time, formatted as an full string.

formatDateAndShortTime

String formatDateAndShortTime()
Formats the the time as a full string. The year is written with four digits, and the time of day will include hour and minute. FormatterFormat ISOYYYY-MM-DD hh:mm EURDD.MM.YYYY hh:mm USMM/DD/YYYY hh:mm

Returns:
The time, formatted as an full string.

formatShortDateAndTime

String formatShortDateAndTime()
Formats the the time as a full string. The year is written with two digits, and the time of day will include hour, minute and second.
FormatterFormat
ISOYY-MM-DD hh:mm:ss
EURDD.MM.YY hh:mm:ss
USMM/DD/YY hh:mm:ss

Returns:
The time, formatted as an full string.

formatShortDateAndLongTime

String formatShortDateAndLongTime()
Formats the the time as a full string. The year is written with two digits, and the time of day will include hour, minute, second and millisecond.
FormatterFormat
ISOYY-MM-DD hh:mm:ss.nnn
EURDD.MM.YY hh:mm:ss.nnn
USMM/DD/YY hh:mm:ss.nnn

Returns:
The time, formatted as an full string.

formatShortDateAndShortTime

String formatShortDateAndShortTime()
Formats the the time as a full string. The year is written with two digits, and the time of day will include hour and minute.
FormatterFormat
ISOYY-MM-DD hh:mm
EURDD.MM.YY hh:mm
USMM/DD/YY hh:mm

Returns:
The time, formatted as an full string.

formatCompactShortDateAndTime

String formatCompactShortDateAndTime()
Formats the the time as a full string. The date is formatted without delimiters and with the year written with two digits. The time of day will include hour, minute and second.
FormatterFormat
ISOYYMMDD hh:mm:ss
EURDDMMYY hh:mm:ss
USMMDDYY hh:mm:ss

Returns:
The time, formatted as an full string.

formatCompactShortDateAndLongTime

String formatCompactShortDateAndLongTime()
Formats the the time as a full string. The date is formatted without delimiters and with the year written with two digits. The time of day will include hour, minute, second and millisecond.
FormatterFormat
ISOYYMMDD hh:mm:ss.nnn
EURDDMMYY hh:mm:ss.nnn
USMMDDYY hh:mm:ss.nnn

Returns:
The time, formatted as an full string.

formatCompactShortDateAndShortTime

String formatCompactShortDateAndShortTime()
Formats the the time as a full string. The date is formatted without delimiters and with the year written with two digits. The time of day will include hour and minute.
FormatterFormat
ISOYYMMDD hh:mm
EURDDMMYY hh:mm
USMMDDYY hh:mm

Returns:
The time, formatted as an full string.


Copyright © 2013. All Rights Reserved.