|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.nc2.units.DateFromString
public class DateFromString
Convenience routines for parsing a String to produce a Date.
Constructor Summary | |
---|---|
DateFromString()
|
Method Summary | |
---|---|
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. |
static java.lang.Double |
getHourUsingDemarkatedMatch(java.lang.String hourString,
java.lang.String formatString,
char demark)
|
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DateFromString()
Method Detail |
---|
public static java.util.Date getDateUsingSimpleDateFormat(java.lang.String dateString, java.lang.String dateFormatString)
dateString
- the String to be parseddateFormatString
- the date format String
public 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 simple 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 character
public 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 character
public static java.lang.Double getHourUsingDemarkatedMatch(java.lang.String hourString, java.lang.String formatString, char demark)
public static java.util.Date getDateUsingCompleteDateFormat(java.lang.String dateString, java.lang.String dateFormatString)
dateString
- the String to be parseddateFormatString
- the date format String
public 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 string
public 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 void main(java.lang.String[] args) throws java.text.ParseException
java.text.ParseException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |