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:
+ *
+ * - YY - year, short - 21
+ * - YYYY - year, full - 2021
+ * - M - month - 1..12 (January is 1)
+ * - Mo - month - 1st..12th (January is 1st)
+ * - MM - month - 01..12 (January is 01)
+ * - MMM - month, short - Jan
+ * - MMMM - month, full - January
+ * - Q - quarter - 1..4 (Jan-March is 1)
+ * - Qo - quarter - 1st..4th (Jan-March is 1st)
+ * - d - day of week - 0..6 (Monday is )
+ * - dd - day of week, 2 characters - Mo, Su
+ * - ddd - day of week, 3 characters - Mon, Sun
+ * - dddd - day of week, full - Monday, Wednesday
+ * - D - day of month - 1..31
+ * - Do - day of month - 1st..31st
+ * - DD - day of month - 01..31
+ * - DDD - day of year - 1..365 (1..366 for leap years)
+ * - DDDo - day of year - 1st..365th (1st..366th for leap years)
+ * - DDDD - day of year - 001..365 (001..366 for leap years)
+ * - w - week of year - 1..53
+ * - wo - week of year - 1st..53rd
+ * - ww - week of year - 01..53
+ * - And more. Formatting currently provided by moment.js, so for a complete list, see
+ * the moment.js cheatsheet.
+ *
+ */
+ 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:
+ *
+ * - YY - year, short - 21
+ * - YYYY - year, full - 2021
+ * - M - month - 1..12 (January is 1)
+ * - Mo - month - 1st..12th (January is 1st)
+ * - MM - month - 01..12 (January is 01)
+ * - MMM - month, short - Jan
+ * - MMMM - month, full - January
+ * - Q - quarter - 1..4 (Jan-March is 1)
+ * - Qo - quarter - 1st..4th (Jan-March is 1st)
+ * - d - day of week - 0..6 (Monday is )
+ * - dd - day of week, 2 characters - Mo, Su
+ * - ddd - day of week, 3 characters - Mon, Sun
+ * - dddd - day of week, full - Monday, Wednesday
+ * - D - day of month - 1..31
+ * - Do - day of month - 1st..31st
+ * - DD - day of month - 01..31
+ * - DDD - day of year - 1..365 (1..366 for leap years)
+ * - DDDo - day of year - 1st..365th (1st..366th for leap years)
+ * - DDDD - day of year - 001..365 (001..366 for leap years)
+ * - w - week of year - 1..53
+ * - wo - week of year - 1st..53rd
+ * - ww - week of year - 01..53
+ * - And more. Formatting currently provided by moment.js, so for a complete list, see
+ * the moment.js cheatsheet.
+ *
+ */
+ 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:
+ *
+ * - YY - year, short - 21
+ * - YYYY - year, full - 2021
+ * - M - month - 1..12 (January is 1)
+ * - Mo - month - 1st..12th (January is 1st)
+ * - MM - month - 01..12 (January is 01)
+ * - MMM - month, short - Jan
+ * - MMMM - month, full - January
+ * - Q - quarter - 1..4 (Jan-March is 1)
+ * - Qo - quarter - 1st..4th (Jan-March is 1st)
+ * - d - day of week - 0..6 (Monday is )
+ * - dd - day of week, 2 characters - Mo, Su
+ * - ddd - day of week, 3 characters - Mon, Sun
+ * - dddd - day of week, full - Monday, Wednesday
+ * - D - day of month - 1..31
+ * - Do - day of month - 1st..31st
+ * - DD - day of month - 01..31
+ * - DDD - day of year - 1..365 (1..366 for leap years)
+ * - DDDo - day of year - 1st..365th (1st..366th for leap years)
+ * - DDDD - day of year - 001..365 (001..366 for leap years)
+ * - w - week of year - 1..53
+ * - wo - week of year - 1st..53rd
+ * - ww - week of year - 01..53
+ * - And more. Formatting currently provided by moment.js, so for a complete list, see
+ * the moment.js cheatsheet.
+ *
+ */
+ public format(formatString: string): string
+ {
+ return this.zonedMoment.format(formatString);
+ }
+
/**
* To ISO-8601 string, e.g. "2020-01-23T17:34:00.000Z"
*/