Package ghidra.util

# Class DateUtils

java.lang.Object
ghidra.util.DateUtils

public class DateUtils extends Object

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `MS_PER_DAY`
  `static final long`
  `MS_PER_HOUR`
  `static final long`
  `MS_PER_MIN`
  `static final long`
  `MS_PER_SEC`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DateUtils()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `formatCurrentTime()`
  Returns the current local time zone time-of-day as simple time string.
  `static String`
  `formatDate(Date date)`
  Formats the given date into a string.
  `static String`
  `formatDateTimestamp(Date date)`
  Formats the given date into a string that contains the date and time.
  `static String`
  `formatDuration(long millis)`
  Formats a millisecond duration as a English string expressing the number of hours, minutes and seconds in the duration
  `static int`
  `getBusinessDaysBetween(Date date1, Date date2)`
  Returns the business days between the two dates.
  `static Date`
  `getDate(int year, int month, int day)`
  Returns a date for the given numeric values
  `static int`
  `getDaysBetween(Date date1, Date date2)`
  Returns all days between the two dates.
  `static List<Date>`
  `getHolidays(int year)`
  `static Date`
  `getNormalizedToday()`
  `static boolean`
  `isHoliday(Calendar cal)`
  `static boolean`
  `isHoliday(Date date)`
  `static boolean`
  `isWeekend(Calendar cal)`
  `static Date`
  `normalizeDate(Date date)`
  `static Date`
  `toDate(LocalDate ld)`
  Converts the given LocalDate to a date
  `static LocalDateTime`
  `toLocalDate(Date d)`
  Converts the given Data to a LocalDate

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### MS_PER_SEC

    public static final long MS_PER_SEC
    See Also:
      - Constant Field Values

  - ### MS_PER_MIN

    public static final long MS_PER_MIN
    See Also:
      - Constant Field Values

  - ### MS_PER_HOUR

    public static final long MS_PER_HOUR
    See Also:
      - Constant Field Values

  - ### MS_PER_DAY

    public static final long MS_PER_DAY
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### DateUtils

    public DateUtils()

- ## Method Details

  - ### getHolidays

    public static List<Date> getHolidays(int year)

  - ### isHoliday

    public static boolean isHoliday(Date date)

  - ### getNormalizedToday

    public static Date getNormalizedToday()

  - ### isHoliday

    public static boolean isHoliday(Calendar cal)

  - ### isWeekend

    public static boolean isWeekend(Calendar cal)

  - ### normalizeDate

    public static Date normalizeDate(Date date)

  - ### formatDate

    public static String formatDate(Date date)
    Formats the given date into a string. This is in contrast to `formatDateTimestamp(Date)`, which will also return the time portion of the date.
    Parameters:
      `date` - the date to format
    Returns:
      the date string

  - ### formatDateTimestamp

    public static String formatDateTimestamp(Date date)
    Formats the given date into a string that contains the date and time. This is in contrast to `formatDate(Date)`, which only returns a date string.
    Parameters:
      `date` - the date to format
    Returns:
      the date and time string

  - ### formatCurrentTime

    public static String formatCurrentTime()
    Returns the current local time zone time-of-day as simple time string. See "h:mm".
    Returns:
      current time-of-day a a string

  - ### toLocalDate

    public static LocalDateTime toLocalDate(Date d)
    Converts the given Data to a LocalDate
    Parameters:
      `d` - the date
    Returns:
      the local date

  - ### toDate

    public static Date toDate(LocalDate ld)
    Converts the given LocalDate to a date
    Parameters:
      `ld` - the local date
    Returns:
      the date

  - ### getDate

    public static Date getDate(int year, int month, int day)
    Returns a date for the given numeric values
    Parameters:
      `year` - the year
      `month` - the month; 0-based
      `day` - the day of month; 1-based
    Returns:
      the date

  - ### getDaysBetween

    public static int getDaysBetween(Date date1, Date date2)
    Returns all days between the two dates. Returns 0 if the same date is passed for both parameters. The order of the dates does not matter.
    Parameters:
      `date1` - the first date
      `date2` - the second date
    Returns:
      the number of days

  - ### getBusinessDaysBetween

    public static int getBusinessDaysBetween(Date date1, Date date2)
    Returns the business days between the two dates. Returns 0 if the same date is passed for both parameters. The order of the dates does not matter.
    Parameters:
      `date1` - the first date
      `date2` - the second date
    Returns:
      the number of days

  - ### formatDuration

    public static String formatDuration(long millis)
    Formats a millisecond duration as a English string expressing the number of hours, minutes and seconds in the duration
    Parameters:
      `millis` - Count of milliseconds of an elapsed duration.
    Returns:
      String such as "5 hours, 3 mins, 22 secs".