public class DateTimeUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DATE_PATTERN_ISO_8601 |
private static List<String> |
datePatternsDigit |
private static List<String> |
datePatternsText |
static String |
DATETIME_PATTERN_ISO_8601 |
private static List<String> |
datetimePatterns |
static String |
OFFSET_PARAM_PATTERN |
static String |
OFFSET_PARAM_REUSE |
static String |
OFFSET_PARAM_UNDEFINED |
static String |
OFFSET_PARAM_Z |
static String |
TIME_PATTERN_ISO_8601 |
private static List<String> |
timeOffsetPatterns |
private static List<String> |
timePatterns |
Constructor and Description |
---|
DateTimeUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
applyOffsetToDatetime(String inputDatetime,
String formattedDatetime,
String offset)
Applies an offset to a datetime
|
static String |
applyOffsetToTime(String inputTime,
String formattedTime,
String offset)
Applies an offset to a time
|
static ZoneOffset |
getOffsetFromDatetime(String datetime)
Tries to detect offset from datetime.
|
static ZoneOffset |
getOffsetFromTime(String time)
Tries to detect offset from time.
|
static DateTimeFormatter |
inferDateFormat(String value)
Tries to infer the date pattern for the given value, then returns a DateTimeFormatter with the inferred
pattern.
|
static DateTimeFormatter |
inferDatetimeFormat(String value,
boolean onlyWithOffset)
Tries to infer the datetime pattern for the given value, then returns a DateTimeFormatter with the
inferred pattern.
|
static DateTimeFormatter |
inferFormatForDate(String value)
Tries to infer the pattern of the input value in order to generate a date, so tries to parse it using
date and datetime patterns (no time patterns since an input time value cannot be converted to a date)
|
static DateTimeFormatter |
inferFormatForDatetime(String value,
boolean onlyWithOffset)
Tries to infer the pattern of the input value in order to generate a datetime, so tries to parse it
using date, time and datetime patterns
|
static DateTimeFormatter |
inferFormatForTime(String value,
boolean onlyWithOffset)
Tries to infer the pattern of the input value in order to generate a time, so tries to parse it using
time and datetime patterns (no date patterns since an input date value cannot be converted to a time)
|
static DateTimeFormatter |
inferTimeFormat(String value,
boolean onlyWithOffset)
Tries to infer the time pattern for the given value, then returns a DateTimeFormatter with the inferred
pattern.
|
static ZoneOffset |
parseOffset(String offset) |
static ZoneOffset |
sumOffsets(ZoneOffset offset1,
ZoneOffset offset2) |
public static final String DATE_PATTERN_ISO_8601
public static final String TIME_PATTERN_ISO_8601
public static final String DATETIME_PATTERN_ISO_8601
public static final String OFFSET_PARAM_UNDEFINED
public static final String OFFSET_PARAM_Z
public static final String OFFSET_PARAM_REUSE
public static final String OFFSET_PARAM_PATTERN
public static DateTimeFormatter inferFormatForDate(String value)
value
- public static DateTimeFormatter inferFormatForTime(String value, boolean onlyWithOffset)
value
- onlyWithOffset
- tells if this method should look only for pattern with timezone offsetpublic static DateTimeFormatter inferFormatForDatetime(String value, boolean onlyWithOffset)
value
- onlyWithOffset
- tells if this method should look only for pattern with timezone offsetpublic static DateTimeFormatter inferDateFormat(String value)
value
- public static DateTimeFormatter inferTimeFormat(String value, boolean onlyWithOffset)
value
- onlyWithOffset
- tells if this method should look only for pattern with timezone offsetpublic static DateTimeFormatter inferDatetimeFormat(String value, boolean onlyWithOffset)
value
- onlyWithOffset
- tells if this method should look only for pattern with timezone offsetpublic static String applyOffsetToTime(String inputTime, String formattedTime, String offset) throws ConverterConfigurationException
inputTime
- input value used to get the offset in case of offset param is "reuse"formattedTime
- time (already formatted according to ISO TIME) to which apply the offsetoffset
- admitted values:
ConverterConfigurationException
public static String applyOffsetToDatetime(String inputDatetime, String formattedDatetime, String offset) throws ConverterConfigurationException
inputDatetime
- input value used to get the offset in case of offset param is "reuse"formattedDatetime
- datetime (already formatted according to ISO DATETIME) to which apply the offsetoffset
- admitted values:
ConverterConfigurationException
public static ZoneOffset getOffsetFromTime(String time)
time
- public static ZoneOffset getOffsetFromDatetime(String datetime)
time
- public static ZoneOffset parseOffset(String offset)
public static ZoneOffset sumOffsets(ZoneOffset offset1, ZoneOffset offset2)
Copyright © 2022 ART Group, University of Rome, Tor Vergata. All rights reserved.