Class TimeConversionUtilities


  • @RequiresApi(api=26)
    public class TimeConversionUtilities
    extends java.lang.Object
    Time conversion utilities to help us handle time.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getDateAndTimeAsString​(java.time.ZonedDateTime date)  
      static java.time.ZonedDateTime getDateWithDefaultTime​(int year, int month, int date)
      Overloaded version, pass in date as year,month and day.
      static java.time.ZonedDateTime getDateWithDefaultTime​(java.time.ZonedDateTime date)  
      static java.time.ZonedDateTime getFirstDayOfMonth()
      Returns first day of current date's month with default times.
      static java.time.ZonedDateTime getFirstDayOfMonth​(java.time.ZonedDateTime date)
      Overloaded version, give date as parameter and method returns first day of that date's year and month.
      static java.time.ZonedDateTime getFirstDayOfWeek()
      Returns first day of current week with default times.
      static java.time.ZonedDateTime getFirstDayOfWeek​(java.time.ZonedDateTime date)
      Overloaded version, pass in date and methods returns first day of that date's week.
      static long getUnixTimeDifference​(long fromTime, long toTime)  
      static java.lang.String makeTimeString​(java.lang.Long hours, java.lang.Long minutes, java.lang.Long seconds)  
      static java.lang.String timeStringFromLong​(java.lang.Long ms)  
      • Methods inherited from class java.lang.Object

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

      • TimeConversionUtilities

        public TimeConversionUtilities()
    • Method Detail

      • getUnixTimeDifference

        public static long getUnixTimeDifference​(long fromTime,
                                                 long toTime)
        Parameters:
        fromTime - Start time in long (epoch)
        toTime - End time in long (epoch)
        Returns:
        return difference between these two times in form of long
      • timeStringFromLong

        public static java.lang.String timeStringFromLong​(java.lang.Long ms)
        Parameters:
        ms - Long variable (epoch) that turns into hh:mm:ss (hours/seconds/minutes)
        Returns:
        String will be transferred into another method "makeTimeString()"
      • makeTimeString

        public static java.lang.String makeTimeString​(java.lang.Long hours,
                                                      java.lang.Long minutes,
                                                      java.lang.Long seconds)
        Parameters:
        hours - Long variable of hours
        minutes - Long variable of minutes
        seconds - Long variable of seconds
        Returns:
        Returns String in a form of hh/mm/ss
      • getDateAndTimeAsString

        public static java.lang.String getDateAndTimeAsString​(java.time.ZonedDateTime date)
        Parameters:
        date - ZonedDateTime that we want to format
        Returns:
        String of ZonedDateTime that looks pretty
      • getDateWithDefaultTime

        public static java.time.ZonedDateTime getDateWithDefaultTime​(java.time.ZonedDateTime date)
        Parameters:
        date - pass in date to convert.
        Returns:
        ZonedDateTime with default time.
      • getDateWithDefaultTime

        public static java.time.ZonedDateTime getDateWithDefaultTime​(int year,
                                                                     int month,
                                                                     int date)
        Overloaded version, pass in date as year,month and day.
        Parameters:
        year -
        month -
        date -
        Returns:
        ZonedDateTime with default time.
      • getFirstDayOfWeek

        public static java.time.ZonedDateTime getFirstDayOfWeek()
        Returns first day of current week with default times.
        Returns:
        ZonedDateTime with default time.
      • getFirstDayOfWeek

        public static java.time.ZonedDateTime getFirstDayOfWeek​(java.time.ZonedDateTime date)
        Overloaded version, pass in date and methods returns first day of that date's week.
        Parameters:
        date -
        Returns:
        ZonedDateTime with default time.
      • getFirstDayOfMonth

        public static java.time.ZonedDateTime getFirstDayOfMonth()
        Returns first day of current date's month with default times.
        Returns:
        ZonedDateTime with default time.
      • getFirstDayOfMonth

        public static java.time.ZonedDateTime getFirstDayOfMonth​(java.time.ZonedDateTime date)
        Overloaded version, give date as parameter and method returns first day of that date's year and month.
        Parameters:
        date -
        Returns:
        ZonedDateTime with default time.