Class JodaDateService

java.lang.Object
restapi.utils.services.date.JodaDateService
All Implemented Interfaces:
DateService

final class JodaDateService extends Object implements DateService
  • Field Details

    • timeZone

      private final org.joda.time.DateTimeZone timeZone
  • Constructor Details

    • JodaDateService

      JodaDateService(org.joda.time.DateTimeZone timeZone)
      Force system-wide timezone to ensure consistent dates over all servers, independently from the region the server is running.
  • Method Details

    • now

      public org.joda.time.DateTime now()
      Specified by:
      now in interface DateService
      Returns:
      current date at the moment of the call
    • nowToString

      public String nowToString()
      Specified by:
      nowToString in interface DateService
      Returns:
      current date at the moment of the call
    • dateToString

      public String dateToString(org.joda.time.DateTime dateTime)
      Specified by:
      dateToString in interface DateService
      Parameters:
      dateTime - in DateTime format
      Returns:
      dateTime in String format
    • dateFromString

      public org.joda.time.DateTime dateFromString(String date)
      Specified by:
      dateFromString in interface DateService
      Parameters:
      date - in String format
      Returns:
      dateTime in DateTime format
    • isOlderThan

      public boolean isOlderThan(org.joda.time.DateTime dateTime, int min)
      Specified by:
      isOlderThan in interface DateService
      Parameters:
      dateTime - date to compare with
      min - minutes that have to have past
      Returns:
      if datetime is older than minutes
    • isOlderThan

      public boolean isOlderThan(String dateTime, int min)
      Specified by:
      isOlderThan in interface DateService
      Parameters:
      dateTime - date to compare with in format String
      min - minutes that have to have past
      Returns:
      if datetime is older than minutes