It allows the user to handle different date representations and formats. It sets up the design and style of how the date will be displayed. The format is defined through a String parameter that adopts unicode date standard. It supports most of the configurations except the formats of the following combinations of localization: MMM, MMMM, MMMMM, zzzz and characters : Y, D, q, Q, W, e, E, A, k, K, j.
CONSTRUCTORS
It initiates DateFormatter with the date of the argument and a displacement in hours equal to utcTime ZoneOffset, regarding the UTC timezone.
Arguments |
|
format |
String: unicode date format. |
utcTimeZoneOffset |
Integer: displacement of hours from UTC |
Exceptions |
TimeZoneOffsetOutOfRange – Error trying to create a Date instance with an out of range timezone offset. Range must be between -18 to +18.. |
It starts DateFormatter with a the format of the date of the argument and displacement 0 (UTC timezone)
Arguments |
|
format |
String: unicode date format. |
It starts DateFormatter with the format “yyyy-MM-dd’T’HH:mm:ss Z” and displacement (UTC timezone).
PUBLIC METHODS
Date dateFromString(String fecha)
It parses and converts the date argument, returning a new Date instance using the format with which the instance DateFormatter was set up.
Arguments |
|
date |
String: date. |
Return |
|
Date |
resulting date. |
Exceptions |
WrongDateFormat – Error trying to create date formatter with invalid format: [DateFormat]. |
String stringFromDate(Date fecha)
It generates the representation in String of the argument date, based on the format with which the instance DateFormatter was set up.
Arguments |
|
date |
Date: date. |
Return |
|
String |
Representation of the resulting date. |
Exceptions |
WrongDateFormat – Error trying to create date formatter with invalid format: ‘DateFormat’. |