Package sk.iway.iwcm

Class DateTools

java.lang.Object
sk.iway.iwcm.DateTools

public class DateTools extends Object
Podporne metody
  • Constructor Details

    • DateTools

      public DateTools()
  • Method Details

    • getMidnightToday

      public static Calendar getMidnightToday()
      Vrati polnoc, koniec dnesneho dna
      Returns:
      calendar
    • getMidnightDaysBefore

      public static Calendar getMidnightDaysBefore(int count)
      Vrati polnoc, zadaj pocet dni dozadu
      Returns:
      calendar
    • getMidninght

      public static Calendar getMidninght(Date date)
      Vrati polnoc, ktorou den zacinal
      Parameters:
      date -
      Returns:
      calendar
    • getHourOfDay

      public static Calendar getHourOfDay(Date date, int hour)
      Vrati hodinu vybrateho dna
      Parameters:
      date -
      Returns:
      calendar
    • getHoursBefore

      public static Calendar getHoursBefore(Date date, int hour)
      Vrati x hodin pred uvedenym casom
      Parameters:
      date -
      hour -
      Returns:
    • midnightToday

      public static Calendar midnightToday(Calendar cal)
      Vrati polnoc ktora bude dnes
      Parameters:
      cal -
      Returns:
      calendar
    • midnightDaysBefore

      public static Calendar midnightDaysBefore(int daysBefore, Calendar cal)
      Vrati polnoc ktorou vybraty den zacinal x dni dozadu
      Parameters:
      cal -
      Returns:
      calendar
    • getFirstDateOfPreviousMonth

      public static Calendar getFirstDateOfPreviousMonth()
      Returns:
    • getLastDateOfPreviousMonth

      public static Calendar getLastDateOfPreviousMonth()
      Returns:
    • getFirstDateOfCurrentMonth

      public static Calendar getFirstDateOfCurrentMonth()
      Returns:
    • getLastDateOfCurrentMonth

      public static Calendar getLastDateOfCurrentMonth()
      Returns:
    • getFirstDateOfNextMonth

      public static Calendar getFirstDateOfNextMonth()
      Returns:
    • getLastDateOfNextMonth

      public static Calendar getLastDateOfNextMonth()
      Returns:
    • hourOfDay

      public static Calendar hourOfDay(Calendar cal, int hour)
      Vrati hodinu dnesneho dna
      Parameters:
      cal -
      Returns:
      calendar
    • dateToCalendar

      public static Calendar dateToCalendar(Date date)
      Konvertuje java.util.Date do java.util.Calendar
      Parameters:
      date -
      Returns:
      calendar
    • timestampToCalendar

      public static Calendar timestampToCalendar(Timestamp timestamp)
      Konvertuje java.sql.Timestamp do java.util.Calendar
      Parameters:
      timestamp -
      Returns:
    • getDaysAfter

      public static Calendar getDaysAfter(int daysAfter, Calendar cal)
      Vrati x dni dopredu, pri zapornom znamienku dni dozadu
      Parameters:
      cal -
      Returns:
      calendar
    • getDatesBetweenInclude

      public static List<Date> getDatesBetweenInclude(Date dateFrom, Date dateTo)
      Vrati list dni medzi dateFrom(vcitane) a dateTo(vcitane)
      Parameters:
      dateFrom -
      dateTo -
      Returns:
    • getDatesBetweenIncludeString

      public static List<String> getDatesBetweenIncludeString(Date dateFrom, Date dateTo)
      Vrati list dni medzi dateFrom(vcitane) a dateTo(vcitane) vystup String skratkaDna.dd.MM.yyyy.skratkaMesiaca
      Parameters:
      dateFrom -
      dateTo -
      Returns:
    • getDatesBetweenIncludeOrderString

      public List<String> getDatesBetweenIncludeOrderString(Date dateFrom, Date dateTo)
      Vrati list dni medzi dateFrom(vcitane) a dateTo(vcitane) vystup String skratkaDna.dd.MM.yyyy.skratkaMesiaca-poradieDna/poradieTyzdna
      Parameters:
      dateFrom -
      dateTo -
      Returns:
    • getShortMonthName

      public static String getShortMonthName(Date datum, Locale locale)
      Vrati skratene nazvy mesiacov pre dany Locale
      Parameters:
      datum -
      locale -
      Returns:
    • getMonthName

      public static String getMonthName(Date datum, Locale locale)
      Vrati nazvy mesiacov pre dany Locale
      Parameters:
      datum -
      locale -
      Returns:
    • getShortDayName

      public static String getShortDayName(Date datum, Locale locale)
      Vrati skratene nazvy dni pre dany Locale
      Parameters:
      datum -
      locale -
      Returns:
    • getDayName

      public static String getDayName(Date datum, Locale locale)
      Vrati nazvy dni pre dany Locale
      Parameters:
      datum -
      locale -
      Returns:
    • getShortDayNames

      public static String[] getShortDayNames(Locale locale)
    • getTimeLongWithoutSeconds

      public long getTimeLongWithoutSeconds(long timeMillisWithSeconds)
      Vrati cas v milisekundach bez sekund a milisekund
      Parameters:
      timeMillisWithSeconds -
      Returns:
    • substractDays

      public static Date substractDays(Date date, int days)
      Odcita dni z datumu
      Parameters:
      date -
      days -
      Returns:
    • addDays

      public static Date addDays(Date date, int days)
      Prida dni k datumu
      Parameters:
      date -
      days -
      Returns:
    • validateRange

      public static int validateRange(Date dateFrom, Date dateTo, Boolean canBeInPast, Boolean canBeSameDay)
      Validates the range between two dates.
      Parameters:
      dateFrom - the starting date of the range
      dateTo - the ending date of the range
      canBeInPast - a flag indicating whether the range can include past dates
      canBeSameDay - a flag indicating whether the range can include the same day
      Returns:
      an integer value representing the validation result:

      -1 if either dateFrom or dateTo is null,

      1 if the range is in the past and canBeInPast is false,

      2 if dateFrom is after dateTo,

      3 if dateFrom is the same as dateTo and canBeSameDay is false,

      0 if the range is valid

    • validateRange

      public static int validateRange(long dateFrom, long dateTo, Boolean canBeInPast, Boolean canBeSameDay)
      Validates the range between two dates.
      Parameters:
      dateFrom - the starting date of the range
      dateTo - the ending date of the range
      canBeInPast - a flag indicating whether the range can be in the past
      canBeSameDay - a flag indicating whether the range can include the same day
      Returns:
      an integer value representing the validation result:

      -1 if either dateFrom or dateTo is negative,

      1 if the range is in the past and canBeInPast is false,

      2 if dateFrom is after dateTo,

      3 if dateFrom is the same as dateTo and canBeSameDay is false,

      0 if the range is valid

    • getDatesBetweenInclude

      public static List<Date> getDatesBetweenInclude(Date dateFrom, Date dateTo, int hourOfDay)
      Vrati list dni medzi dateFrom(vratane) a dateTo(vratane), vynuluje casou zlozku a nastavi hodinu
      Parameters:
      dateFrom -
      dateTo -
      hourOfDay -
      Returns:
    • getDaysBetween

      public static long getDaysBetween(Date dateFrom, Date dateTo)
    • setTimePart

      public static Date setTimePart(long date, int hour, int minute, int second, int millisecond)
    • setTimePart

      public static Date setTimePart(Date date, int hour, int minute, int second, int millisecond)
    • timePartDiff

      public static long timePartDiff(Date from, Date to)
      Return in milliseconds time difference between two TIME parts of the given dates (date part is ignored)
      Parameters:
      from -
      to -
      Returns:
    • getFirstDateOfMonth

      public static Calendar getFirstDateOfMonth(Date date, int monthShift)
    • getLastDateOfMonth

      public static Calendar getLastDateOfMonth(Date date, int monthShift)