diff --git a/src/LocalDate.ts b/src/LocalDate.ts index 6e50cb2..23afec1 100644 --- a/src/LocalDate.ts +++ b/src/LocalDate.ts @@ -44,6 +44,42 @@ export class LocalDate ); } + /** + * Writes this {@link ZonedDateTime} as a string in specified format, and returns it. + * @param formatString The format in which to write the date. The following substrings + * (expressed in bold) will get translated to the the following values: + * + */ + public format(formatString: string): string + { + return this.toMoment().format(formatString); + } + /** * To ISO-8601 string, e.g. "2020-01-23" */ diff --git a/src/LocalDateTime.ts b/src/LocalDateTime.ts index 92c5130..44aa04c 100644 --- a/src/LocalDateTime.ts +++ b/src/LocalDateTime.ts @@ -129,6 +129,42 @@ export class LocalDateTime return this.time.millisecond; } + /** + * Writes this {@link ZonedDateTime} as a string in specified format, and returns it. + * @param formatString The format in which to write the date. The following substrings + * (expressed in bold) will get translated to the the following values: + * + */ + public format(formatString: string): string + { + return this.toMoment().format(formatString); + } + /** * To ISO-8601 string, e.g. "2020-01-23T17:34:00.000" */ diff --git a/src/ZonedDateTime.ts b/src/ZonedDateTime.ts index e5491ce..a7e22c9 100644 --- a/src/ZonedDateTime.ts +++ b/src/ZonedDateTime.ts @@ -109,6 +109,42 @@ export class ZonedDateTime return this.zonedMoment.millisecond(); } + /** + * Writes this {@link ZonedDateTime} as a string in specified format, and returns it. + * @param formatString The format in which to write the date. The following substrings + * (expressed in bold) will get translated to the the following values: + * + */ + public format(formatString: string): string + { + return this.zonedMoment.format(formatString); + } + /** * To ISO-8601 string, e.g. "2020-01-23T17:34:00.000Z" */