Converts the provided date into a string representation based on the specified format.
Optional
input: DateThe date to be formatted. If not provided, the current date and time will be used.
The formatted date as a string.
// Create a SimpleDateFormat instance with the desired format
const formatter = new ix.api.text.SimpleDateFormat("dd.MM.yyyy");
// Format a specific date
const formattedDate = formatter.format(new Date(2021, 1 - 1, 01));
console.log(formattedDate); // Outputs: "01.01.2021"
Parses the provided string into a Date object based on the format specified when the SimpleDateFormat instance was created.
The string to be parsed into a Date object.
Optional
baseDate: DateAn optional base date used for parsing. If not provided, the current date and time will be used.
A Date object representing the parsed date, or undefined
if the input string cannot be parsed into a valid date.
// Create a SimpleDateFormat instance with the desired format
const formatter = new ix.api.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
// Parse a string into a Date object
const parsedDate = formatter.parse("2021-01-01T20:55:43.000Z");
console.log(parsedDate);
// Outputs: Fri Jan 01 2021 20:55:43 GMT+0100 (Central European Standard Time)
The
SimpleDateFormat
class serves as a wrapper for the Moment.js library. It mimics the functionality ofjava.text.SimpleDateFormat
, providing a familiar interface for Java developers.To learn more about Moment.js, refer to its official documentation.