public class Iso8601UtilLimitedImpl extends Object implements Iso8601UtilLimited
Iso8601UtilLimited interface. It does NOT use
SimpleDateFormat. All methods of this class are fast and thread-safe. Iso8601UtilImpl| Modifier and Type | Field and Description |
|---|---|
private static Iso8601UtilLimitedImpl |
instance |
protected static int |
MAX_DAY_OF_MONTH
The maximum day of the month.
|
protected static int |
MAX_MONTH
The maximum month of the year.
|
PATTERN_STRING_ALL, PATTERN_STRING_DATE, PATTERN_STRING_TIME, PATTERN_STRING_TIMEZONE| Constructor and Description |
|---|
Iso8601UtilLimitedImpl()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
formatDate(Date date)
This method formats the given
date in the format "yyyy-MM-dd" in GMT according to ISO 8601. |
String |
formatDate(Date date,
boolean extended)
This method formats the given
calendar as a date in the format "yyyy-MM-dd" according to
ISO 8601. |
void |
formatDate(Date date,
boolean extended,
Appendable buffer)
This method formats the given
date as a date according to ISO 8601. |
void |
formatDate(int year,
int month,
int day,
boolean extended,
Appendable buffer) |
String |
formatDateTime(Date date)
This method formats the given
date as a date and time in the format "yyyy-MM-ddTHH:mm:ssZ" (UTC) according
to ISO 8601. |
String |
formatDateTime(Date date,
boolean extendedDate,
boolean extendedTime,
boolean extendedTimezone)
This method formats the given
date as a date according to ISO 8601. |
void |
formatDateTime(Date date,
boolean extendedDate,
boolean extendedTime,
boolean extendedTimeZone,
Appendable buffer)
This method formats the given
date as a date and time according to ISO 8601. |
void |
formatTime(Date date,
boolean extended,
Appendable buffer)
This method formats the given
date as time according to ISO 8601. |
void |
formatTime(int hours,
int minutes,
int seconds,
boolean extended,
Appendable buffer) |
void |
formatTimeZone(int timezoneOffset,
boolean extended,
Appendable buffer)
This method formats the given
timezone according to ISO 8601. |
static Iso8601UtilLimited |
getInstance()
This method gets the singleton instance of this
Iso8601UtilImpl. |
protected int[] |
parseDate(CharSequenceScanner scanner)
This method parses the date from the given
scanner. |
Date |
parseDate(String dateIso8601)
This method parses the given string
date according to ISO 8601. |
protected int[] |
parseTime(CharSequenceScanner scanner)
This method parses the time (or timezone offset) from the given
scanner. |
protected Integer |
parseTimezoneOffset(CharSequenceScanner scanner)
This method parses the timezone offset from the given
scanner. |
private int |
read2Digits(CharSequenceScanner scanner)
This method reads two digits from the given
scanner. |
protected static final int MAX_DAY_OF_MONTH
protected static final int MAX_MONTH
private static Iso8601UtilLimitedImpl instance
public static Iso8601UtilLimited getInstance()
Iso8601UtilImpl. Cdi.GET_INSTANCE before using.public String formatDate(Date date)
Iso8601UtilLimiteddate in the format "yyyy-MM-dd" in GMT according to ISO 8601.formatDate in interface Iso8601UtilLimiteddate - is the Date to format.date as date string.public String formatDate(Date date, boolean extended)
Iso8601UtilLimitedcalendar as a date in the format "yyyy-MM-dd" according to
ISO 8601.formatDate in interface Iso8601UtilLimiteddate - is the Date to format.extended - if false the basic format ("yyyyMMdd") is used, if true the extended format
("yyyy-MM-dd") is used.calendar as date string.public void formatDate(Date date, boolean extended, Appendable buffer)
Iso8601UtilLimiteddate as a date according to ISO 8601.formatDate in interface Iso8601UtilLimiteddate - is the Date to format.extended - if false the basic date format ("yyyyMMdd") is used, if true the extended date
format ("yyyy-MM-dd") is used.buffer - is where to append the formatted date.public void formatDate(int year,
int month,
int day,
boolean extended,
Appendable buffer)
year - is the yearmonth - is the month (1-12).day - is the day.extended - if false the basic date format ("yyyyMMdd") is used, if true the extended date
format ("yyyy-MM-dd") is used.buffer - is where to append the formatted date.formatDate(Date, boolean, Appendable)public String formatDateTime(Date date)
Iso8601UtilLimiteddate as a date and time in the format "yyyy-MM-ddTHH:mm:ssZ" (UTC) according
to ISO 8601.formatDateTime in interface Iso8601UtilLimiteddate - is the date to format.calendar as date string.public String formatDateTime(Date date, boolean extendedDate, boolean extendedTime, boolean extendedTimezone)
Iso8601UtilLimiteddate as a date according to ISO 8601.formatDateTime in interface Iso8601UtilLimiteddate - is the Date to format.extendedDate - if false the basic date format ("yyyyMMdd") is used, if true the extended date
format ("yyyy-MM-dd") is used.extendedTime - if false the basic time format ("HHmmss") is used, if true the extended time
format ("HH:mm:ss") is used.extendedTimezone - if false the basic timezone format ("±HHmm[ss]") is used, if true the
extended timezone format ("±HH:mm[:ss]") is used.calendar as date string.public void formatDateTime(Date date, boolean extendedDate, boolean extendedTime, boolean extendedTimeZone, Appendable buffer)
Iso8601UtilLimiteddate as a date and time according to ISO 8601.formatDateTime in interface Iso8601UtilLimiteddate - is the Date to format.extendedDate - if false the basic date format ("yyyyMMdd") is used, if true the extended date
format ("yyyy-MM-dd") is used.extendedTime - if false the basic time format ("HHmmss") is used, if true the extended time
format ("HH:mm:ss") is used.extendedTimeZone - if false the basic timezone format ("±HHmm[ss]") is used, if true the
extended timezone format ("±HH:mm[:ss]") is used.buffer - is where to append the formatted date and time.public void formatTime(Date date, boolean extended, Appendable buffer)
Iso8601UtilLimiteddate as time according to ISO 8601.formatTime in interface Iso8601UtilLimiteddate - is the Date to format.extended - if false the basic time format ("HHmmss") is used, if true the extended time format
("HH:mm:ss") is used.buffer - is where to append the formatted date.public void formatTime(int hours,
int minutes,
int seconds,
boolean extended,
Appendable buffer)
hours - are the hours.minutes - are the minutes.seconds - are the seconds.extended - if false the basic time format ("HHmmss") is used, if true the extended time format
("HH:mm:ss") is used.buffer - is where to append the formatted date.formatTime(Date, boolean, Appendable)public void formatTimeZone(int timezoneOffset,
boolean extended,
Appendable buffer)
Iso8601UtilLimitedformatTimeZone in interface Iso8601UtilLimitedtimezoneOffset - is the timezone-offset in milliseconds.extended - - if false the basic timezone format ("±HHmm[ss]") is used, if true the
extended timezone format ("±HH:mm[:ss]") is used.buffer - is where to append the formatted timezone.public Date parseDate(String dateIso8601)
Iso8601UtilLimiteddate according to ISO 8601.parseDate in interface Iso8601UtilLimiteddateIso8601 - is the date to parse.protected Integer parseTimezoneOffset(CharSequenceScanner scanner)
scanner.scanner - is the parser pointing to the timezone or at the end of the string.null for UTC (Z) or if no timezone is present.protected int[] parseDate(CharSequenceScanner scanner)
scanner. The format is yyyy[-]MM[-]dd.scanner - is the parser pointing to the date.private int read2Digits(CharSequenceScanner scanner) throws IllegalDateFormatException
scanner.scanner - is the scanner potentially pointing to the digits.-1 if the scanner does NOT point to a digit or the number represented by the two digits
consumed from the scanner.IllegalDateFormatException - if the scanner only contained a single digit.protected int[] parseTime(CharSequenceScanner scanner)
scanner. The format is
hh[[:]mm[[:]ss]].scanner - is the parser pointing to the time.Copyright © 2001–2016 mmm-Team. All rights reserved.