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 TimeZone
createTimezone
(String timeZone) private static String
cutLeadingZeroAndPlus
(String value) private static String
formatTimezone
(int min) static String
setLeadingZero
(double value) static String
setLeadingZero
(int value) static Calendar
Converts a String object that contains a ISO8601 conform value to an java.util.Calendar object.static Calendar
toGregorianDate
(double julianDate) Converts a julian date into a gregorian date.static Calendar
toGregorianDate
(double julianDate, TimeZone zone) Converts a julian date into a gregorian date.static String
Converts a Date object into a String object that represents a ISO8601 conform string.static double
toJulianDate
(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 (ifNULL
is 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
null
if 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
null
if the given string wasnull
or empty. - Throws:
NumberFormatException
- if given ISO8601 is malformed.
-
createTimezone
- Throws:
NumberFormatException
-
setLeadingZero
-
setLeadingZero
-
cutLeadingZeroAndPlus
-
formatTimezone
-