DefaultDateParser parses many date formats to a string.
The supported date formats are:
- yyyy-MM-dd (^\\d{4}\\-\\d{2}\\-\\d{2}$)
- yyyyMMdd (^\\d{8}$)
- yyyy-MM-dd HH:mm:ss (^\\d{4}\\-\\d{2}\\-\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}$)
- yyyyMMdd HHmmss (^\\d{8}\\s+\\d{6}$)
- yyyyMMdd HH:mm:ss (^\\d{8}\\s+\\d{2}:\\d{2}:\\d{2}$)
- yyyy-MM-dd HHmmss (^\\d{4}\\-\\d{2}\\-\\d{2}\\s+\\d{6}$)
- T (^T$)
Date formats can be added using DefaultDateParser#register(String, String).
These modifiers are supported:
- T+?S (add ? milliseconds to T, T can be any valid date format with modifiers)
- T-?S (subtract ? milliseconds from T, idem)
- T+?s (add ? seconds to T, idem)
- T-?s (subtract ? seconds from T, idem)
- T+?m (add ? minutes to T, idem)
- T-?m (subtract ? minutes from T, idem)
- T+?H (add ? hours to T, idem)
- T-?H (subtract ? hours from T, idem)
- T+?d (add ? hours to T, idem)
- T-?d (subtract ? hours from T, idem)
- T+?w (add ? weeks to T, idem)
- T-?w (subtract ? weeks from T, idem)
- T+?M (add ? months to T, idem)
- T-?M (subtract ? months from T, idem)
- T+?y (add ? years to T, idem)
- T-?y (subtract ? years from T, idem)
- T<s (shift T to start of current second, idem)
- T>s (shift T to start of next second, idem)
- T<m (shift T to start of current minute, idem)
- T>m (shift T to start of next minute, idem)
- T<H (shift T to start of current hour, idem)
- T>H (shift T to start of next hour, idem)
- T<d (shift T to start of current day, idem)
- T>d (shift T to start of next day, idem)
- T<w (shift T to start of current week, idem)
- T>w (shift T to start of next week, idem)
- T<y (shift T to start of current year, idem)
- T>y (shift T to start of next year, idem)
Modifiers can be added using DefaultDateParser#register(String, DateModifier).
Modifiers can be combined and are parsed from left to right, for example:
2005-04-09 23:30:00>M+10d+8H
results in 2005-05-11 08:00:00
.
@author Steven Devijver
@since 25-04-2005