public final class ParseDateExtensions extends java.lang.Object implements DatePatterns
DD_MMM_YY, DOT_DD_MM, DOT_DD_MM_YY, DOT_DD_MM_YYYY, DOT_DD_MM_YYYY_HH_MM_SS, DOT_YYYY_MM_DD_HH_MM_SS, EEE_MMM_DD_HH_MM_SS_Z_YYYY, EEEE_MMM_DD_YYYY, LHH_MM_SS, UHH_MM, UHH_MM_SS, YYYY_MM_DD, YYYY_MM_DD_HH_MM_SS, YYYY_MM_DD_HH_MM_SS_S, YYYY_MM_DD_T_HH_MM_SS, YYYYMMDDHHMMSS| Modifier and Type | Method and Description |
|---|---|
static java.util.Date |
parseDate(java.lang.String date,
java.util.List<java.lang.String> patterns)
Tries to convert the given String to a Date.
|
static java.util.Date |
parseToDate(java.lang.String date,
java.lang.String format)
Parses the String date to a date object.
|
static java.util.Date |
parseToDate(java.lang.String datum,
java.lang.String[] formats,
java.util.Locale locale)
Returns a date-object if the array with the formats are valid otherwise null.
|
static java.util.Date |
parseToDateLenient(java.lang.String date,
java.lang.String format,
boolean lenient)
Parses the String date to a date object.
|
static java.lang.String |
parseToString(java.util.Date date,
java.lang.String format)
The Method parseToString(Date, String) formats the given Date to the given Format.
|
static java.lang.String |
parseToString(java.util.Date date,
java.lang.String format,
java.util.Locale locale)
The Method parseToString(Date, String) formats the given Date to the given Format.
|
static java.lang.String |
parseToString(java.lang.String date,
java.lang.String currentformat,
java.lang.String newFormat)
The Method parseToString(String, String, String) formats the given Date as string from the
current Format to the new given Format.
|
public static java.util.Date parseDate(java.lang.String date,
java.util.List<java.lang.String> patterns)
date - The date to convert as String.patterns - The date patterns to convert the String to a date-object.public static java.util.Date parseToDate(java.lang.String date,
java.lang.String format)
throws java.text.ParseException
date - The Date as Stringformat - The Format for the Date to parsejava.text.ParseException - occurs when their are problems with parsing the String to Date.public static java.util.Date parseToDate(java.lang.String datum,
java.lang.String[] formats,
java.util.Locale locale)
datum - The date as string which to parse to a date-object.formats - The string-array with the date-patterns.locale - THe Locale for the SimpleDateFormat.public static java.util.Date parseToDateLenient(java.lang.String date,
java.lang.String format,
boolean lenient)
date - The Date as Stringformat - The Format for the Date to parselenient - Specify whether or not date/time interpretation is to be lenient.public static java.lang.String parseToString(java.util.Date date,
java.lang.String format)
date - The Date to format to a Stringformat - The Format for the datepublic static java.lang.String parseToString(java.util.Date date,
java.lang.String format,
java.util.Locale locale)
date - The Date to format to a Stringformat - The Format for the datelocale - The Locale object in which Language to get the format string.public static java.lang.String parseToString(java.lang.String date,
java.lang.String currentformat,
java.lang.String newFormat)
throws java.text.ParseException
String expected = "20120810";
String actual = ParseDateUtils.parseToString(
ParseDateUtils.parseToDate("10.08.2012", "dd.MM.yyyy"), "yyyyMMdd");
date - The date as String object that shell be parsed to the new formatcurrentformat - The current format from the datenewFormat - The new format for the output date as String objectjava.text.ParseException - occurs when their are problems with parsing the String to Date.