Class DateTimeUtils

java.lang.Object
org.bardframework.commons.utils.DateTimeUtils

public class DateTimeUtils extends Object
Created by Vahid Zafari on 8/12/2016.
  • Field Details

  • Constructor Details

    • DateTimeUtils

      public DateTimeUtils()
  • Method Details

    • getNowUtc

      public static long getNowUtc()
    • getTodayUtc

      public static long getTodayUtc()
    • toEpochMills

      public static long toEpochMills(LocalDateTime dateTime)
    • toEpochMills

      public static long toEpochMills(LocalDateTime dateTime, ZoneOffset offset)
    • fromEpochMills

      public static LocalDateTime fromEpochMills(long dateAsMills)
    • fromEpochMills

      public static LocalDateTime fromEpochMills(long dateTimeAsMills, ZoneId zone)
      Obtains an instance of LocalDateTime using milliseconds from the epoch of 1970-01-01T00:00:00Z.
      Parameters:
      dateTimeAsMills - the number of milliseconds after 1970-01-01T00:00:00Z
      zone - the zone
      Returns:
      a LocalDateTime, not null
    • diffDays

      public static long diffDays(long startDateEpochMills, long endDateEpochMills)
    • leftDays

      public static long leftDays(long startDateEpochMills)
    • remainDays

      public static long remainDays(long endDateEpochMills)
    • toEpochMills

      public static long toEpochMills(LocalDate date)
      calculate milliseconds past from the epoch of 1970-01-01T00:00:00Z.
      Parameters:
      date - an instance of (@code LocalDate)
      Returns:
      past milliseconds from 1970-01-01T00:00:00Z according (!@code date) at 23:59:59:99:999.
      Throws:
      IllegalArgumentException - if null date passed to method.