public class ISODateIO extends Object
Calendar
for convenience.
Format of the scanner can be composed of %? directive which define components
of the time. These directives are listed below. For example, the format
"%F %T", which is equivalent to "%Y-%m-%d %H:%M:%S" can parse the following
timestamp: "2010-12-09 03:45:39";
Modifier and Type | Field and Description |
---|---|
protected LinkedList<ISODateComponent> |
components
List of components, build from a string format.
|
private static ISODateComponent[] |
KNOWN_COMPONENTS |
protected Pattern |
pattern
The regular expression builds from the components.
|
Constructor and Description |
---|
ISODateIO()
Create a scanner with default format "%K".
|
ISODateIO(String format)
Create a new scanner with a given format.
|
Modifier and Type | Method and Description |
---|---|
protected void |
buildRegularExpression()
Build a regular expression from the components of the scanner.
|
protected LinkedList<ISODateComponent> |
findComponents(String format)
Build a list of component from a string.
|
Pattern |
getPattern()
Get the current pattern used to parse timestamp.
|
Calendar |
parse(String time)
Parse a string which should be in the scanner format.
|
void |
setFormat(String format)
Set the format of this scanner.
|
String |
toString(Calendar calendar)
Convert a calendar into a string according to the format of this object.
|
private static final ISODateComponent[] KNOWN_COMPONENTS
protected LinkedList<ISODateComponent> components
public ISODateIO() throws ParseException
ParseException
public ISODateIO(String format) throws ParseException
format
- format of the scanner.ParseException
- if bad directives foundpublic Pattern getPattern()
protected LinkedList<ISODateComponent> findComponents(String format) throws ParseException
format
- format of the scannerParseException
- if invalid component foundprotected void buildRegularExpression()
public void setFormat(String format) throws ParseException
format
- new format of the scannerParseException
- if an error is found in the new formatpublic Calendar parse(String time)
time
- timestamp in the scanner formatWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses