Package jmri.util

Class DateUtil


  • public class DateUtil
    extends java.lang.Object
    Common utility methods for working with Calendar and Date objects.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.GregorianCalendar calFromJulianDate​(long julianDay)
      Return a GregorianCalendar representation of the given julian date.
      static long julianDayFromCalendar​(java.util.GregorianCalendar cal)
      Return a julian date representation of the given GregorianCalendar date.
      static java.lang.String userDurationFromSeconds​(int seconds)
      For a given number of seconds, format to a more human readable form.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • calFromJulianDate

        public static java.util.GregorianCalendar calFromJulianDate​(long julianDay)
        Return a GregorianCalendar representation of the given julian date. For reference, see: http://aa.usno.navy.mil/faq/docs/JD_Formula.php
        Parameters:
        julianDay - number of days since January 1,4713BC.
        Returns:
        GregorianCalendar representation of julianDay
      • julianDayFromCalendar

        public static long julianDayFromCalendar​(java.util.GregorianCalendar cal)
        Return a julian date representation of the given GregorianCalendar date. for reference, see: http://aa.usno.navy.mil/faq/docs/JD_Formula.php
        Parameters:
        cal - the GregorianCalendar to convert.
        Returns:
        julianDate representation of the date represented by cal.
      • userDurationFromSeconds

        public static java.lang.String userDurationFromSeconds​(int seconds)
        For a given number of seconds, format to a more human readable form. Negative durations are prepended by the minus symbol. For durations less than 24hrs, the day integer is omitted.
        Parameters:
        seconds - the number of seconds
        Returns:
        string representation of duration in D hh:mm:ss form.