Package org.esa.snap.core.util
Class DateTimeUtils
- java.lang.Object
- 
- org.esa.snap.core.util.DateTimeUtils
 
- 
- 
Field SummaryFields Modifier and Type Field Description static doubleHOURS_PER_DAYThe number of hours per day.static SimpleDateFormatISO_8601_FORMATAn ISO 8601 date/time format.static SimpleDateFormatISO_8601_UTC_FORMATstatic doubleJD_OFFSETThe number of days from noon Jan 1, 4713 BC (Proleptic Julian) to midnight 1/1/1970 AD (Gregorian).static doubleMICROS_PER_DAYThe number of micro-seconds per day.static doubleMILLIS_PER_DAYThe number of milli-seconds per day.static doubleMJD_OFFSETThe Modified Julian Day (MJD) gives the number of days since midnight on November 17, 1858.static doubleSECONDS_PER_DAYThe number of seconds per day.
 - 
Constructor SummaryConstructors Constructor Description DateTimeUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static Dateaverage(Date startDate, Date endDate)Computes the median (average) of two dates.static ProductData.UTCaverage(ProductData.UTC startDate, ProductData.UTC endDate)Computes the median (average) of twoProductData.UTCdata structures.static LocalDateTimecalendarToLocalDateTime(Calendar utc)Converts a UTC date/time calendar to a LocalDateTime.static doublejdToMJD(double jd)Converts a julian day (JD) to a modified julian day (MJD) value.static DatejdToUTC(double jd)Converts a julian day (JD) to a UTC date/time value.static doublemjdToJD(double mjd)Converts a modified julian day (MJD) to a julian day (JD) value.static ProductData.UTCparseDate(String stringData, String dateFormat)Utility method for returning aProductData.UTCdate from a string using the given date format.static DatestringToUTC(String utc)Converts a UTC date/time string to a UTC date/time value.static doubleutcToJD(Date utc)Converts a UTC date/time value to a julian day (JD).static StringutcToString(Date utc)Converts a UTC date/time value to a string.
 
- 
- 
- 
Field Detail- 
ISO_8601_FORMATpublic static final SimpleDateFormat ISO_8601_FORMAT An ISO 8601 date/time format. This does not give UTC times.
 - 
ISO_8601_UTC_FORMATpublic static final SimpleDateFormat ISO_8601_UTC_FORMAT 
 - 
JD_OFFSETpublic static final double JD_OFFSET The number of days from noon Jan 1, 4713 BC (Proleptic Julian) to midnight 1/1/1970 AD (Gregorian). 1/1/1970 is time zero for a java.util.Date.- See Also:
- Constant Field Values
 
 - 
MJD_OFFSETpublic static final double MJD_OFFSET The Modified Julian Day (MJD) gives the number of days since midnight on November 17, 1858. This date corresponds toMJD_OFFSET = 2400000.5days after day zero of the Julian calendar.- See Also:
- Constant Field Values
 
 - 
HOURS_PER_DAYpublic static final double HOURS_PER_DAY The number of hours per day.- See Also:
- Constant Field Values
 
 - 
SECONDS_PER_DAYpublic static final double SECONDS_PER_DAY The number of seconds per day.- See Also:
- Constant Field Values
 
 - 
MILLIS_PER_DAYpublic static final double MILLIS_PER_DAY The number of milli-seconds per day.- See Also:
- Constant Field Values
 
 - 
MICROS_PER_DAYpublic static final double MICROS_PER_DAY The number of micro-seconds per day.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
jdToMJDpublic static double jdToMJD(double jd) Converts a julian day (JD) to a modified julian day (MJD) value.- Parameters:
- jd- the julian day
- Returns:
- the modified julian day
 
 - 
mjdToJDpublic static double mjdToJD(double mjd) Converts a modified julian day (MJD) to a julian day (JD) value.- Parameters:
- mjd- the modified julian day
- Returns:
- the julian day
 
 - 
jdToUTCpublic static Date jdToUTC(double jd) Converts a julian day (JD) to a UTC date/time value.Important note: Due to the limitations of java.util.Datethis method does not take leap seconds into account.- Parameters:
- jd- the julian day
- Returns:
- the UTC date/time
 
 - 
utcToJDpublic static double utcToJD(Date utc) Converts a UTC date/time value to a julian day (JD).Important note: Due to the limitations of java.util.Datethis method does not take leap seconds into account.- Parameters:
- utc- the UTC date/time, if- nullthe current time is converted
- Returns:
- the julian day
 
 - 
utcToStringpublic static String utcToString(Date utc) Converts a UTC date/time value to a string. The method uses the ISO 8601 date/time formatYYYY-MM-DD hh:mm:ss.SImportant note: Due to the limitations of java.util.Datethis method does not take leap seconds into account.- Parameters:
- utc- the UTC date/time value
- Returns:
- the UTC date/time string
 
 - 
stringToUTCpublic static Date stringToUTC(String utc) throws ParseException Converts a UTC date/time string to a UTC date/time value. The method uses the ISO 8601 date/time formatYYYY-MM-DD hh:mm:ss.S.Important note: Due to the limitations of java.util.Datethis method does not take leap seconds into account.- Parameters:
- utc- the UTC date/time string
- Throws:
- ParseException
 
 - 
calendarToLocalDateTimepublic static LocalDateTime calendarToLocalDateTime(Calendar utc) Converts a UTC date/time calendar to a LocalDateTime. The method interpretes this UTC value as a MJD 2000 date (Modified Julian Day where the first day is the 01.01.2000).- Parameters:
- utc- the UTC date/time calendar
 
 - 
averagepublic static Date average(Date startDate, Date endDate) Computes the median (average) of two dates. This method handles the possible overflow that can occur.- Parameters:
- startDate- The first date
- endDate- The second date
- Returns:
- The date between the two input dates
 
 - 
averagepublic static ProductData.UTC average(ProductData.UTC startDate, ProductData.UTC endDate) Computes the median (average) of twoProductData.UTCdata structures.- Parameters:
- startDate- The first date
- endDate- The second date
- Returns:
- The date between the two input dates
 
 - 
parseDatepublic static ProductData.UTC parseDate(String stringData, String dateFormat) Utility method for returning aProductData.UTCdate from a string using the given date format. Why not usingProductData.UTC.parse(text, pattern)method? Because it errors in the case of a format like dd-MM-yyyy'T'HH:mm:ss.SSSSSS (which should be perfectly fine).- Parameters:
- stringData- The string to be converted into a date
- dateFormat- The format of the string date
- Returns:
- The UTC date representation.
 
 
- 
 
-