Package de.lehmannet.om.util
Class DateConverter
java.lang.Object
de.lehmannet.om.util.DateConverter
The DateConverter is a helper class that provides methods for
handling the all kind of date formats.
E.g. the ISO8601 date format (A short summary about the ISO8601 date format can be accessed at the W3C.), or the Julian date.
E.g. the ISO8601 date format (A short summary about the ISO8601 date format can be accessed at the W3C.), or the Julian date.
- Since:
- 1.0
- Author:
- doergn@users.sourceforge.net
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static TimeZonecreateTimezone(String timeZone) private static StringcutLeadingZeroAndPlus(String value) private static StringformatTimezone(int min) static StringsetLeadingZero(double value) static StringsetLeadingZero(int value) static CalendarConverts a String object that contains a ISO8601 conform value to an java.util.Calendar object.static CalendartoGregorianDate(double julianDate) Converts a julian date into a gregorian date.static CalendartoGregorianDate(double julianDate, TimeZone zone) Converts a julian date into a gregorian date.static StringConverts a Date object into a String object that represents a ISO8601 conform string.static doubletoJulianDate(Calendar gregorianCalendar) Converts a gregorian date into a julian date.
-
Field Details
-
DATE_DELIMITER
- See Also:
-
TIME_DELIMITER
- See Also:
-
DATETIME_DELIMITER
- See Also:
-
UTC_TIMEZONE_OFFSET
- See Also:
-
-
Constructor Details
-
DateConverter
public DateConverter()
-
-
Method Details
-
toJulianDate
Converts a gregorian date into a julian date.- Parameters:
gregorianDate- The gregorianDate date- Returns:
- A julian date with seconds accuracy
-
toGregorianDate
Converts a julian date into a gregorian date.- Parameters:
julianDate- The julian date- Returns:
- A gregorian date with seconds accuracy (Timezone = GMT)
-
toGregorianDate
Converts a julian date into a gregorian date.- Parameters:
julianDate- The julian datezone- The timzone for the returned gregorian date (ifNULLis passed GMT will be taken)- Returns:
- A gregorian date
-
toISO8601
Converts a Date object into a String object that represents a ISO8601 conform string.- Parameters:
calendar- A java.util.Date object that has to be converted- Returns:
- A ISO8601 conform String, or
nullif the given date wasnull
-
toDate
Converts a String object that contains a ISO8601 conform value to an java.util.Calendar object.- Parameters:
iso8601- A String with a ISO8601 conform value- Returns:
- The parameters date as java.util.Calendar, or
nullif the given string wasnullor empty. - Throws:
NumberFormatException- if given ISO8601 is malformed.
-
createTimezone
- Throws:
NumberFormatException
-
setLeadingZero
-
setLeadingZero
-
cutLeadingZeroAndPlus
-
formatTimezone
-