Package amadeus.perception
Class DateConverter
java.lang.Object
amadeus.perception.DateConverter
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatDate(Object date) Formats a date or date-time object into a user-friendly string.static voidMain method for testing theDateConverterclass.static ObjectParses a date string into aLocalDateorLocalDateTimeobject.
-
Constructor Details
-
DateConverter
public DateConverter()
-
-
Method Details
-
parseDate
Parses a date string into aLocalDateorLocalDateTimeobject.Supports multiple date and time formats. If the input string does not match any supported format, an
AmadeusExceptionis thrown.- Parameters:
dateString- the date string to parse; must not benull.- Returns:
- a
LocalDateorLocalDateTimeobject. - Throws:
AmadeusException- if the input string cannot be parsed into a valid date or date-time.
-
formatDate
Formats a date or date-time object into a user-friendly string.- Parameters:
date- the date or date-time object to format; must not benull.- Returns:
- the formatted date string (e.g., "Oct 15 2019" or "Oct 15 2019, 6:00PM").
-
main
Main method for testing theDateConverterclass.- Parameters:
args- command-line arguments (not used).
-