Package org.ofbiz.core.util
Class UtilDateTime
java.lang.Object
org.ofbiz.core.util.UtilDateTime
Utility class for handling java.util.Date, the java.sql data/time classes and related information
- Since:
- 2.0
- Version:
- $Revision: 1.1 $
- Author:
- David E. Jones, Andy Zeneski
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Timestampstatic Timestampstatic TimestampgetDayStart(Timestamp stamp) static TimestampgetDayStart(Timestamp stamp, int daysLater) static TimestampgetNextDayStart(Timestamp stamp) static TimestampMakes a Timestamp for the beginning of the monthstatic DatenowDate()Return a Date for right nowstatic TimestampReturn a Timestamp for right nowstatic DatetoDate(int month, int day, int year, int hour, int minute, int second) Makes a Date from separate ints for month, day, year, hour, minute, and second.static DateConverts a date and time String into a Datestatic DateConverts a date String and a time String into a Datestatic DatetoDate(String monthStr, String dayStr, String yearStr, String hourStr, String minuteStr, String secondStr) Makes a Date from separate Strings for month, day, year, hour, minute, and second.static StringtoDateString(Date date) Makes a date String in the format MM/DD/YYYY from a Datestatic StringtoDateTimeString(Date date) Makes a combined data and time string in the format "MM/DD/YYYY HH:MM:SS" from a Date.static DatetoSqlDate(int month, int day, int year) Makes a java.sql.Date from separate ints for month, day, yearstatic DateConverts a date String into a java.sql.Datestatic DateMakes a java.sql.Date from separate Strings for month, day, yearstatic TimetoSqlTime(int hour, int minute, int second) Makes a java.sql.Time from separate ints for hour, minute, and second.static TimeConverts a time String into a java.sql.Timestatic TimeMakes a java.sql.Time from separate Strings for hour, minute, and second.static TimestamptoTimestamp(int month, int day, int year, int hour, int minute, int second) Makes a Timestamp from separate ints for month, day, year, hour, minute, and second.static TimestamptoTimestamp(String dateTime) Converts a date and time String into a Timestampstatic TimestamptoTimestamp(String date, String time) Converts a date String and a time String into a Timestampstatic TimestamptoTimestamp(String monthStr, String dayStr, String yearStr, String hourStr, String minuteStr, String secondStr) Makes a Timestamp from separate Strings for month, day, year, hour, minute, and second.static StringtoTimeString(int hour, int minute, int second) Makes a time String in the format HH:MM:SS from a separate ints for hour, minute, and second.static StringtoTimeString(Date date) Makes a time String in the format HH:MM:SS from a Date.
-
Constructor Details
-
UtilDateTime
public UtilDateTime()
-
-
Method Details
-
nowTimestamp
Return a Timestamp for right now- Returns:
- Timestamp for right now
-
nowDate
Return a Date for right now- Returns:
- Date for right now
-
getDayStart
-
getDayStart
-
getNextDayStart
-
getDayEnd
-
getDayEnd
-
toSqlDate
Converts a date String into a java.sql.Date- Parameters:
date- The date String: MM/DD/YYYY- Returns:
- A java.sql.Date made from the date String
-
toSqlDate
Makes a java.sql.Date from separate Strings for month, day, year- Parameters:
monthStr- The month StringdayStr- The day StringyearStr- The year String- Returns:
- A java.sql.Date made from separate Strings for month, day, year
-
toSqlDate
Makes a java.sql.Date from separate ints for month, day, year- Parameters:
month- The month intday- The day intyear- The year int- Returns:
- A java.sql.Date made from separate ints for month, day, year
-
toSqlTime
Converts a time String into a java.sql.Time- Parameters:
time- The time String: either HH:MM or HH:MM:SS- Returns:
- A java.sql.Time made from the time String
-
toSqlTime
Makes a java.sql.Time from separate Strings for hour, minute, and second.- Parameters:
hourStr- The hour StringminuteStr- The minute StringsecondStr- The second String- Returns:
- A java.sql.Time made from separate Strings for hour, minute, and second.
-
toSqlTime
Makes a java.sql.Time from separate ints for hour, minute, and second.- Parameters:
hour- The hour intminute- The minute intsecond- The second int- Returns:
- A java.sql.Time made from separate ints for hour, minute, and second.
-
toTimestamp
Converts a date and time String into a Timestamp- Parameters:
dateTime- A combined data and time string in the format "MM/DD/YYYY HH:MM:SS", the seconds are optional- Returns:
- The corresponding Timestamp
-
toTimestamp
Converts a date String and a time String into a Timestamp- Parameters:
date- The date String: MM/DD/YYYYtime- The time String: either HH:MM or HH:MM:SS- Returns:
- A Timestamp made from the date and time Strings
-
toTimestamp
public static Timestamp toTimestamp(String monthStr, String dayStr, String yearStr, String hourStr, String minuteStr, String secondStr) Makes a Timestamp from separate Strings for month, day, year, hour, minute, and second.- Parameters:
monthStr- The month StringdayStr- The day StringyearStr- The year StringhourStr- The hour StringminuteStr- The minute StringsecondStr- The second String- Returns:
- A Timestamp made from separate Strings for month, day, year, hour, minute, and second.
-
toTimestamp
Makes a Timestamp from separate ints for month, day, year, hour, minute, and second.- Parameters:
month- The month intday- The day intyear- The year inthour- The hour intminute- The minute intsecond- The second int- Returns:
- A Timestamp made from separate ints for month, day, year, hour, minute, and second.
-
toDate
Converts a date and time String into a Date- Parameters:
dateTime- A combined data and time string in the format "MM/DD/YYYY HH:MM:SS", the seconds are optional- Returns:
- The corresponding Date
-
toDate
Converts a date String and a time String into a Date- Parameters:
date- The date String: MM/DD/YYYYtime- The time String: either HH:MM or HH:MM:SS- Returns:
- A Date made from the date and time Strings
-
toDate
public static Date toDate(String monthStr, String dayStr, String yearStr, String hourStr, String minuteStr, String secondStr) Makes a Date from separate Strings for month, day, year, hour, minute, and second.- Parameters:
monthStr- The month StringdayStr- The day StringyearStr- The year StringhourStr- The hour StringminuteStr- The minute StringsecondStr- The second String- Returns:
- A Date made from separate Strings for month, day, year, hour, minute, and second.
-
toDate
Makes a Date from separate ints for month, day, year, hour, minute, and second.- Parameters:
month- The month intday- The day intyear- The year inthour- The hour intminute- The minute intsecond- The second int- Returns:
- A Date made from separate ints for month, day, year, hour, minute, and second.
-
toDateString
Makes a date String in the format MM/DD/YYYY from a Date- Parameters:
date- The Date- Returns:
- A date String in the format MM/DD/YYYY
-
toTimeString
Makes a time String in the format HH:MM:SS from a Date. If the seconds are 0, then the output is in HH:MM.- Parameters:
date- The Date- Returns:
- A time String in the format HH:MM:SS or HH:MM
-
toTimeString
Makes a time String in the format HH:MM:SS from a separate ints for hour, minute, and second. If the seconds are 0, then the output is in HH:MM.- Parameters:
hour- The hour intminute- The minute intsecond- The second int- Returns:
- A time String in the format HH:MM:SS or HH:MM
-
toDateTimeString
Makes a combined data and time string in the format "MM/DD/YYYY HH:MM:SS" from a Date. If the seconds are 0 they are left off.- Parameters:
date- The Date- Returns:
- A combined data and time string in the format "MM/DD/YYYY HH:MM:SS" where the seconds are left off if they are 0.
-
monthBegin
Makes a Timestamp for the beginning of the month- Returns:
- A Timestamp of the beginning of the month
-