Skip to content

Commit

Permalink
Fixed some errors and added more tests
Browse files Browse the repository at this point in the history
* Corrected ChronoUnit for DAYS_IN_YEAR_ISO_8601
* Corrected behaviour of SSSS
* Corrected behaviour when specifying year 0
* Added more tests for time patterns
  • Loading branch information
normanj-bitquill committed Jul 5, 2024
1 parent d2fcac1 commit 5386e6b
Show file tree
Hide file tree
Showing 3 changed files with 402 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public enum ChronoUnitEnum {
ISO_8601,
CENTURIES),
DAYS_IN_YEAR_ISO_8601(
ChronoUnit.YEARS,
ChronoUnit.DAYS,
ISO_8601,
YEARS_ISO_8601),
WEEKS_IN_YEAR_ISO_8601(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,7 @@ public class PostgresqlDateTimeFormatter {
24 * 60 * 60 - 1,
5,
dt -> Integer.toString(dt.get(ChronoField.SECOND_OF_DAY)),
"SSSSS"),
new NumberFormatPattern(
ChronoUnitEnum.SECONDS_IN_DAY,
0,
9999,
4,
dt -> Integer.toString(dt.get(ChronoField.SECOND_OF_DAY)),
"SSSS"),
"SSSSS", "SSSS"),
new NumberFormatPattern(
ChronoUnitEnum.SECONDS_IN_MINUTE,
0,
Expand Down Expand Up @@ -169,13 +162,15 @@ public class PostgresqlDateTimeFormatter {
Integer.MAX_VALUE,
4,
dt -> String.format(Locale.ROOT, "%04d", dt.getYear()),
year -> year == 0 ? 1 : year,
"YYYY"),
new NumberFormatPattern(
ChronoUnitEnum.YEARS_ISO_8601,
0,
Integer.MAX_VALUE,
4,
dt -> Integer.toString(dt.get(IsoFields.WEEK_BASED_YEAR)),
year -> year == 0 ? 1 : year,
"IYYY"),
new NumberFormatPattern(
ChronoUnitEnum.YEARS_IN_MILLENIA_ISO_8601,
Expand Down
Loading

0 comments on commit 5386e6b

Please sign in to comment.