Class DateConverter

java.lang.Object
amadeus.perception.DateConverter

public class DateConverter extends Object
A utility class for parsing and formatting dates and date-times.

This class supports multiple date and time formats, allowing flexible input from users. It can parse strings into LocalDate or LocalDateTime objects and format these objects into user-friendly strings.

  • Constructor Details

    • DateConverter

      public DateConverter()
  • Method Details

    • parseDate

      public static Object parseDate(String dateString) throws AmadeusException
      Parses a date string into a LocalDate or LocalDateTime object.

      Supports multiple date and time formats. If the input string does not match any supported format, an AmadeusException is thrown.

      Parameters:
      dateString - the date string to parse; must not be null.
      Returns:
      a LocalDate or LocalDateTime object.
      Throws:
      AmadeusException - if the input string cannot be parsed into a valid date or date-time.
    • formatDate

      public static String formatDate(Object date)
      Formats a date or date-time object into a user-friendly string.
      Parameters:
      date - the date or date-time object to format; must not be null.
      Returns:
      the formatted date string (e.g., "Oct 15 2019" or "Oct 15 2019, 6:00PM").
    • main

      public static void main(String[] args)
      Main method for testing the DateConverter class.
      Parameters:
      args - command-line arguments (not used).