public class ParseDateUtils extends 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 Date |
parseDate(String date,
List<String> patterns)
Tries to convert the given String to a Date.
|
static Date |
parseToDate(String date,
String format)
Parses the String date to a date object.
|
static Date |
parseToDate(String datum,
String[] formats,
Locale locale)
Returns a date-object if the array with the formats are valid otherwise null.
|
static Date |
parseToDateLenient(String date,
String format,
boolean lenient)
Parses the String date to a date object.
|
static String |
parseToString(Date date,
String format)
The Method parseToString(Date, String) formats the given Date to the given Format.
|
static String |
parseToString(Date date,
String format,
Locale locale)
The Method parseToString(Date, String) formats the given Date to the given Format.
|
static String |
parseToString(String date,
String currentformat,
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 Date parseDate(String date, List<String> patterns)
date - The date to convert as String.patterns - The date patterns to convert the String to a date-object.public static Date parseToDate(String date, String format) throws ParseException
date - The Date as Stringformat - The Format for the Date to parseParseException - occurs when their are problems with parsing the String to Date.public static Date parseToDate(String datum, String[] formats, 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 Date parseToDateLenient(String date, 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 String parseToString(Date date, String format)
date - The Date to format to a Stringformat - The Format for the datepublic static String parseToString(Date date, String format, 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 String parseToString(String date, String currentformat, String newFormat) throws 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 objectParseException - occurs when their are problems with parsing the String to Date.Copyright © 2015 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.