Class TimeUtil
- java.lang.Object
-
- de.fraunhofer.iese.mydata.policy.time.TimeUtil
-
public class TimeUtil extends Object
Operations for ZonedDateTime, Zone and MyDataTimeExpressions- Author:
- Robin Brandstaedter
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALWAYS
static String
DAY
static String
HOURS
static String
LAST_HOUR
static String
LAST_MINUTE
static String
LAST_MONTH
static String
LAST_SUN_WEEK
static String
LAST_WEEK
static String
LAST_YEAR
static org.slf4j.Logger
LOG
static String
MINUTES
static String
MONTH
static String
NOW
static String
SECONDS
static String
THIS_HOUR
static String
THIS_MINUTE
static String
THIS_MONTH
static String
THIS_SUN_WEEK
static String
THIS_WEEK
static String
THIS_YEAR
static String
TODAY
static String
YEAR
static String
YESTERDAY
-
Constructor Summary
Constructors Constructor Description TimeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.time.ZonedDateTime
addDay(int value, java.time.ZonedDateTime aZonedDateTime)
static java.time.ZonedDateTime
addHours(int value, java.time.ZonedDateTime aZonedDateTime)
static java.time.ZonedDateTime
addMinutes(int value, java.time.ZonedDateTime aZonedDateTime)
static java.time.ZonedDateTime
addMonth(int value, java.time.ZonedDateTime aZonedDateTime)
static java.time.ZonedDateTime
addSeconds(int value, java.time.ZonedDateTime aZonedDateTime)
static java.time.ZonedDateTime
addYear(int value, java.time.ZonedDateTime aZonedDateTime)
static java.time.ZonedDateTime
addYear(String expressionValue, java.time.ZonedDateTime aZonedDateTime)
static java.time.ZonedDateTime
getDynamicZonedDateTime(Map<String,String> expressionMap, java.time.ZonedDateTime timeRelativeTo)
static Map<String,String>
getExpressionMap(String expression)
static String
getHighestRelativeChangeUnit(TimeExpression timeExpression)
static TimeInterval
getInterval(String fixedExpression, java.time.ZonedDateTime timeRelativeTo)
static TimeInterval
getInterval(String fixedExpression, java.time.ZonedDateTime timeRelativeTo, String sDayOfWeek)
static String
getLowestConcreteUnit(TimeExpression timeExpression)
static long
getMillisFromZonedDateTime(java.time.ZonedDateTime zdt, String targetZoneId)
static java.time.ZonedDateTime
getNow(String timezoneid)
static java.time.ZonedDateTime
getNow(java.time.ZoneId zoneId)
static int
getValenceOfUnitString(String unit)
static java.time.ZonedDateTime
getZonedDateTime(String dateString, String timezoneid)
static java.time.ZonedDateTime
getZonedDateTime(String dateString, java.time.ZoneId zoneId)
static java.time.ZonedDateTime
getZonedDateTime(Timestamp ts, String timezoneid)
static boolean
isValid(TimeExpression timeExpression)
static java.time.ZonedDateTime
parseExpressionToZonedDateTime(String expression, java.time.ZonedDateTime timeRelativeTo)
Parses the expression and returns the zoned date time.static TimeExpression
splittMap(Map<String,String> expressionMap)
static java.time.ZonedDateTime
transferToZone(java.time.ZonedDateTime zdt, String timeZoneId)
static java.time.ZonedDateTime
transferToZone(java.time.ZonedDateTime zdt, java.time.ZoneId zoneId)
-
-
-
Field Detail
-
LOG
public static final org.slf4j.Logger LOG
-
NOW
public static final String NOW
- See Also:
- Constant Field Values
-
YEAR
public static final String YEAR
- See Also:
- Constant Field Values
-
MONTH
public static final String MONTH
- See Also:
- Constant Field Values
-
DAY
public static final String DAY
- See Also:
- Constant Field Values
-
HOURS
public static final String HOURS
- See Also:
- Constant Field Values
-
MINUTES
public static final String MINUTES
- See Also:
- Constant Field Values
-
SECONDS
public static final String SECONDS
- See Also:
- Constant Field Values
-
THIS_MINUTE
public static final String THIS_MINUTE
- See Also:
- Constant Field Values
-
LAST_MINUTE
public static final String LAST_MINUTE
- See Also:
- Constant Field Values
-
THIS_HOUR
public static final String THIS_HOUR
- See Also:
- Constant Field Values
-
LAST_HOUR
public static final String LAST_HOUR
- See Also:
- Constant Field Values
-
TODAY
public static final String TODAY
- See Also:
- Constant Field Values
-
YESTERDAY
public static final String YESTERDAY
- See Also:
- Constant Field Values
-
THIS_MONTH
public static final String THIS_MONTH
- See Also:
- Constant Field Values
-
LAST_MONTH
public static final String LAST_MONTH
- See Also:
- Constant Field Values
-
THIS_YEAR
public static final String THIS_YEAR
- See Also:
- Constant Field Values
-
LAST_YEAR
public static final String LAST_YEAR
- See Also:
- Constant Field Values
-
ALWAYS
public static final String ALWAYS
- See Also:
- Constant Field Values
-
THIS_WEEK
public static final String THIS_WEEK
- See Also:
- Constant Field Values
-
LAST_WEEK
public static final String LAST_WEEK
- See Also:
- Constant Field Values
-
THIS_SUN_WEEK
public static final String THIS_SUN_WEEK
- See Also:
- Constant Field Values
-
LAST_SUN_WEEK
public static final String LAST_SUN_WEEK
- See Also:
- Constant Field Values
-
-
Method Detail
-
parseExpressionToZonedDateTime
public static java.time.ZonedDateTime parseExpressionToZonedDateTime(String expression, java.time.ZonedDateTime timeRelativeTo)
Parses the expression and returns the zoned date time.- Parameters:
expression
- e.g., "10.10.2016 00:00:00", "*.-1.* *:*:*",...timeRelativeTo
- the time relative to now/event- Returns:
- the zoned date time
- Throws:
IllegalArgumentException
- the invalid format exception
-
getInterval
public static TimeInterval getInterval(String fixedExpression, java.time.ZonedDateTime timeRelativeTo)
-
getInterval
public static TimeInterval getInterval(String fixedExpression, java.time.ZonedDateTime timeRelativeTo, String sDayOfWeek)
-
getDynamicZonedDateTime
public static java.time.ZonedDateTime getDynamicZonedDateTime(Map<String,String> expressionMap, java.time.ZonedDateTime timeRelativeTo)
-
addYear
public static java.time.ZonedDateTime addYear(int value, java.time.ZonedDateTime aZonedDateTime)
-
addMonth
public static java.time.ZonedDateTime addMonth(int value, java.time.ZonedDateTime aZonedDateTime)
-
addDay
public static java.time.ZonedDateTime addDay(int value, java.time.ZonedDateTime aZonedDateTime)
-
addHours
public static java.time.ZonedDateTime addHours(int value, java.time.ZonedDateTime aZonedDateTime)
-
addMinutes
public static java.time.ZonedDateTime addMinutes(int value, java.time.ZonedDateTime aZonedDateTime)
-
addSeconds
public static java.time.ZonedDateTime addSeconds(int value, java.time.ZonedDateTime aZonedDateTime)
-
addYear
public static java.time.ZonedDateTime addYear(String expressionValue, java.time.ZonedDateTime aZonedDateTime)
-
splittMap
public static TimeExpression splittMap(Map<String,String> expressionMap)
-
getNow
public static java.time.ZonedDateTime getNow(String timezoneid)
-
getNow
public static java.time.ZonedDateTime getNow(java.time.ZoneId zoneId)
-
transferToZone
public static java.time.ZonedDateTime transferToZone(java.time.ZonedDateTime zdt, String timeZoneId)
-
transferToZone
public static java.time.ZonedDateTime transferToZone(java.time.ZonedDateTime zdt, java.time.ZoneId zoneId)
-
getHighestRelativeChangeUnit
public static String getHighestRelativeChangeUnit(TimeExpression timeExpression)
-
getLowestConcreteUnit
public static String getLowestConcreteUnit(TimeExpression timeExpression)
-
getValenceOfUnitString
public static int getValenceOfUnitString(String unit)
-
isValid
public static boolean isValid(TimeExpression timeExpression)
-
getZonedDateTime
public static java.time.ZonedDateTime getZonedDateTime(String dateString, String timezoneid)
-
getZonedDateTime
public static java.time.ZonedDateTime getZonedDateTime(Timestamp ts, String timezoneid)
-
getZonedDateTime
public static java.time.ZonedDateTime getZonedDateTime(String dateString, java.time.ZoneId zoneId)
-
getMillisFromZonedDateTime
public static long getMillisFromZonedDateTime(java.time.ZonedDateTime zdt, String targetZoneId)
-
-