Package org.openbravo.scheduling
Class SchedulerTimeUtils
- java.lang.Object
-
- org.openbravo.scheduling.SchedulerTimeUtils
-
public class SchedulerTimeUtils extends Object
Provides utility methods that help to deal with dates when scheduling a process.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
currentDate(String format)
Formats the current date using a specific format.static String
format(Date date, String format)
Formats the provided date using a specific format.static String
getCurrentDateTime(String date, String time)
Returns current DateTime as formatted String to be used in the parse/timestamp method If date or time is missing, it will assume now for that part, if both are present it will keep themstatic LocalDateTime
parse(String dateTime)
Utility method to parse a date with time String into aLocalDateTime
.static Date
timestamp(String dateTime)
Utility method to parse a date with time String into aDate
.
-
-
-
Method Detail
-
timestamp
public static Date timestamp(String dateTime) throws ParseException
Utility method to parse a date with time String into aDate
.- Parameters:
dateTime
- A date with time as a String. Expected format: 'dd-MM-yyyy HH:mm:ss' If missing, current date and time is returned.- Returns:
- a
Date
with the provided date and time. - Throws:
ParseException
- if the provided date and time can not be parsed to create theDate
instance.
-
parse
public static LocalDateTime parse(String dateTime) throws ParseException
Utility method to parse a date with time String into aLocalDateTime
.- Parameters:
dateTime
- A date with time as a String. Expected format: 'dd-MM-yyyy HH:mm:ss'- Returns:
- a
LocalDateTime
with the provided date and time. - Throws:
ParseException
- if the provided date and time can not be parsed to create theLocalDateTime
instance.
-
getCurrentDateTime
public static String getCurrentDateTime(String date, String time)
Returns current DateTime as formatted String to be used in the parse/timestamp method If date or time is missing, it will assume now for that part, if both are present it will keep them- Parameters:
date
- Date in format dd-MM-yyyytime
- Time in format HH:mm:ss- Returns:
- Current DateTime as String formatted as "dd-MM-yyyy HH:mm:ss", if any parameter missing, it will assume current
-
currentDate
public static String currentDate(String format)
Formats the current date using a specific format.- Parameters:
format
- the date time format to be applied.- Returns:
- a String with the current date time formatted with the provided format.
-
-