-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests. New method to format dates with chosen number of digits.
- Loading branch information
Showing
7 changed files
with
224 additions
and
32 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/main/java/com/ethlo/time/AbstractInternetDateTimeUtil.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,43 @@ | ||
package com.ethlo.time; | ||
|
||
import java.time.DateTimeException; | ||
|
||
public abstract class AbstractInternetDateTimeUtil implements InternetDateTimeUtil | ||
{ | ||
private final static int MAX_FRACTION_DIGITS = 9; | ||
|
||
private final boolean unknownLocalOffsetConvention; | ||
|
||
public AbstractInternetDateTimeUtil(boolean unknownLocalOffsetConvention) | ||
{ | ||
this.unknownLocalOffsetConvention = unknownLocalOffsetConvention; | ||
} | ||
|
||
/** | ||
* RFC 3339 - 4.3. Unknown Local Offset Convention | ||
* | ||
* If the time in UTC is known, but the offset to local time is unknown, | ||
* this can be represented with an offset of "-00:00". This differs | ||
* semantically from an offset of "Z" or "+00:00", which imply that UTC | ||
* is the preferred reference point for the specified time. | ||
* | ||
* @return True if allowed, otherwise false | ||
*/ | ||
public boolean allowUnknownLocalOffsetConvention() | ||
{ | ||
return unknownLocalOffsetConvention; | ||
} | ||
|
||
protected void failUnknownLocalOffsetConvention() | ||
{ | ||
throw new DateTimeException("Unknown Local Offset Convention date-times not allowed. See #allowUnknownLocalOffsetConvention()"); | ||
} | ||
|
||
protected void assertMaxFractionDigits(int fractionDigits) | ||
{ | ||
if (fractionDigits > MAX_FRACTION_DIGITS ) | ||
{ | ||
throw new DateTimeException("Maximum support number of fraction dicits in second is " + MAX_FRACTION_DIGITS + ", got " + fractionDigits); | ||
} | ||
} | ||
} |
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
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.