public class DateFromString
extends java.lang.Object
Constructor and Description |
---|
DateFromString() |
Modifier and Type | Method and Description |
---|---|
static java.util.Date |
getDateUsingCompleteDateFormat(java.lang.String dateString,
java.lang.String dateFormatString)
Parse the given date string using the given date format string (as
described in java.text.SimpleDateFormat) and return a Date.
|
static java.util.Date |
getDateUsingCompleteDateFormatWithOffset(java.lang.String dateString,
java.lang.String dateFormatString,
int startIndex)
Parse the given date string (starting at the given startIndex) using the
given date format string (as described in java.text.SimpleDateFormat) and
return a Date.
|
static java.util.Date |
getDateUsingDemarkatedCount(java.lang.String dateString,
java.lang.String dateFormatString,
char demark)
Parse the given date string, starting at a position given by the offset of the demark character in the
dateFormatString.
|
static java.util.Date |
getDateUsingDemarkatedMatch(java.lang.String dateString,
java.lang.String dateFormatString,
char demark)
Parse the given date string (between the demarcation characters)
using the given date format string (as described in
java.text.SimpleDateFormat) and return a Date.
|
static java.util.Date |
getDateUsingRegExp(java.lang.String dateString,
java.lang.String matchPattern,
java.lang.String substitutionPattern)
Use regular expression capture group replacement to construct a date
string and return the Date that is obtained by parseing the constructed
date string using the date format string "yyyy-MM-dd'T'HH:mm".
|
static java.util.Date |
getDateUsingRegExpAndDateFormat(java.lang.String dateString,
java.lang.String matchPattern,
java.lang.String substitutionPattern,
java.lang.String dateFormatString)
The same as getDateUsingRegExp() except the date format string to be used
must be specified.
|
static java.util.Date |
getDateUsingSimpleDateFormat(java.lang.String dateString,
java.lang.String dateFormatString)
Parse the given date string (starting at the first numeric character)
using the given date format string (as described in
java.text.SimpleDateFormat) and return a Date.
|
public static java.util.Date getDateUsingCompleteDateFormat(java.lang.String dateString, java.lang.String dateFormatString)
dateString
- the String to be parseddateFormatString
- the date format Stringpublic static java.util.Date getDateUsingCompleteDateFormatWithOffset(java.lang.String dateString, java.lang.String dateFormatString, int startIndex)
dateString
- the String to be parseddateFormatString
- the date format StringstartIndex
- the index at which to start parsing the date stringpublic static java.util.Date getDateUsingDemarkatedCount(java.lang.String dateString, java.lang.String dateFormatString, char demark)
Example: dateString = wrfout_d01_2006-07-06_080000.nc dateFormatString = wrfout_d01_#yyyy-MM-dd_HHmmThis simply counts over "wrfout_d01_" number of chars in dateString, then applies the remaining dateFormatString.
dateString
- the String to be parseddateFormatString
- the date format Stringdemark
- the demarkation characterpublic static java.util.Date getDateUsingDemarkatedMatch(java.lang.String dateString, java.lang.String dateFormatString, char demark)
Example: dateString = /data/anything/2006070611/wrfout_d01_2006-07-06_080000.nc dateFormatString = #wrfout_d01_#yyyy-MM-dd_HHmm would extract the date 2006-07-06T08:00 dateString = /data/anything/2006070611/wrfout_d01_2006-07-06_080000.nc dateFormatString = yyyyMMddHH#/wrfout_d01_# would extract the date 2006-07-06T11:00
dateString
- the String to be parseddateFormatString
- the date format Stringdemark
- the demarkation characterpublic static java.util.Date getDateUsingRegExp(java.lang.String dateString, java.lang.String matchPattern, java.lang.String substitutionPattern)
dateString
- the String to be parsedmatchPattern
- the regular expression String on which to match.substitutionPattern
- the String to use in the capture group replacement.public static java.util.Date getDateUsingRegExpAndDateFormat(java.lang.String dateString, java.lang.String matchPattern, java.lang.String substitutionPattern, java.lang.String dateFormatString)
dateString
- the String to be parsedmatchPattern
- the regular expression String on which to match.substitutionPattern
- the String to use in the capture group replacement.dateFormatString
- the date format string to use in the parsing of the date string.public static java.util.Date getDateUsingSimpleDateFormat(java.lang.String dateString, java.lang.String dateFormatString)
dateString
- the String to be parseddateFormatString
- the date format String