generated from GoodforGod/java-library-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from GoodforGod/dev
[1.1.0
- Loading branch information
Showing
55 changed files
with
1,229 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
133 changes: 133 additions & 0 deletions
133
src/main/java/io/goodforgod/gson/configuration/DateTimeFormatters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package io.goodforgod.gson.configuration; | ||
|
||
import static java.time.temporal.ChronoField.*; | ||
|
||
import java.time.chrono.IsoChronology; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeFormatterBuilder; | ||
import java.time.format.ResolverStyle; | ||
import java.time.format.SignStyle; | ||
|
||
/** | ||
* ISO8601 formats and patterns | ||
* | ||
* @author Anton Kurako (GoodforGod) | ||
* @since 05.11.2021 | ||
*/ | ||
public final class DateTimeFormatters { | ||
|
||
private DateTimeFormatters() {} | ||
|
||
/** | ||
* uuuu | ||
*/ | ||
public static final DateTimeFormatter ISO_YEAR = new DateTimeFormatterBuilder() | ||
.appendValue(YEAR, 4, 4, SignStyle.EXCEEDS_PAD) | ||
.toFormatter() | ||
.withResolverStyle(ResolverStyle.STRICT) | ||
.withChronology(IsoChronology.INSTANCE); | ||
|
||
/** | ||
* uuuu-MM | ||
*/ | ||
public static final DateTimeFormatter ISO_YEAR_MONTH = new DateTimeFormatterBuilder() | ||
.append(ISO_YEAR) | ||
.appendLiteral('-') | ||
.appendValue(MONTH_OF_YEAR, 2) | ||
.toFormatter() | ||
.withResolverStyle(ResolverStyle.STRICT) | ||
.withChronology(IsoChronology.INSTANCE); | ||
|
||
/** | ||
* MM-dd | ||
*/ | ||
public static final DateTimeFormatter ISO_MONTH_DAY = new DateTimeFormatterBuilder() | ||
.appendValue(MONTH_OF_YEAR, 2) | ||
.appendLiteral('-') | ||
.appendValue(DAY_OF_MONTH, 2) | ||
.toFormatter() | ||
.withResolverStyle(ResolverStyle.STRICT) | ||
.withChronology(IsoChronology.INSTANCE); | ||
|
||
/** | ||
* @see DateTimeFormatter#ISO_INSTANT | ||
*/ | ||
public static final DateTimeFormatter ISO_INSTANT = DateTimeFormatter.ISO_INSTANT; | ||
|
||
/** | ||
* uuuu-MM-dd | ||
*/ | ||
public static final DateTimeFormatter ISO_LOCAL_DATE = new DateTimeFormatterBuilder() | ||
.append(ISO_YEAR_MONTH) | ||
.appendLiteral('-') | ||
.appendValue(DAY_OF_MONTH, 2) | ||
.toFormatter() | ||
.withResolverStyle(ResolverStyle.STRICT) | ||
.withChronology(IsoChronology.INSTANCE); | ||
|
||
/** | ||
* HH:mm:ss.SSS | ||
*/ | ||
public static final DateTimeFormatter ISO_LOCAL_TIME = new DateTimeFormatterBuilder() | ||
.appendValue(HOUR_OF_DAY, 2) | ||
.appendLiteral(':') | ||
.appendValue(MINUTE_OF_HOUR, 2) | ||
.optionalStart() | ||
.appendLiteral(':') | ||
.appendValue(SECOND_OF_MINUTE, 2) | ||
.optionalStart() | ||
.appendFraction(NANO_OF_SECOND, 3, 3, true) | ||
.optionalEnd() | ||
.toFormatter() | ||
.withResolverStyle(ResolverStyle.STRICT); | ||
|
||
/** | ||
* uuuu-MM-dd'T'HH:mm:ss.SSS | ||
*/ | ||
public static final DateTimeFormatter ISO_LOCAL_DATE_TIME = new DateTimeFormatterBuilder() | ||
.append(ISO_LOCAL_DATE) | ||
.appendLiteral('T') | ||
.append(ISO_LOCAL_TIME) | ||
.toFormatter() | ||
.withResolverStyle(ResolverStyle.STRICT) | ||
.withChronology(IsoChronology.INSTANCE); | ||
|
||
/** | ||
* HH:mm:ss.SSSXXX | ||
*/ | ||
public static final DateTimeFormatter ISO_OFFSET_TIME = new DateTimeFormatterBuilder() | ||
.append(ISO_LOCAL_TIME) | ||
.appendOffsetId() | ||
.toFormatter() | ||
.withResolverStyle(ResolverStyle.STRICT); | ||
|
||
/** | ||
* uuuu-MM-dd'T'HH:mm:ss.SSSXXX | ||
*/ | ||
public static final DateTimeFormatter ISO_OFFSET_DATE_TIME = new DateTimeFormatterBuilder() | ||
.append(ISO_LOCAL_DATE_TIME) | ||
.appendOffsetId() | ||
.toFormatter() | ||
.withResolverStyle(ResolverStyle.STRICT) | ||
.withChronology(IsoChronology.INSTANCE); | ||
|
||
/** | ||
* uuuu-MM-dd'T'HH:mm:ss.SSSXXX[VV] | ||
*/ | ||
public static final DateTimeFormatter ISO_ZONED_DATE_TIME = new DateTimeFormatterBuilder() | ||
.append(ISO_OFFSET_DATE_TIME) | ||
.optionalStart() | ||
.appendLiteral('[') | ||
.parseCaseSensitive() | ||
.appendZoneRegionId() | ||
.appendLiteral(']') | ||
.optionalEnd() | ||
.toFormatter() | ||
.withResolverStyle(ResolverStyle.STRICT) | ||
.withChronology(IsoChronology.INSTANCE); | ||
|
||
/** | ||
* ISO8601 for {@link java.util.Date} and {@link java.sql.Timestamp} | ||
*/ | ||
public static final String ISO_DATE = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.