Package jsonvalues
Class JsInstant
java.lang.Object
jsonvalues.JsPrimitive
jsonvalues.JsInstant
- All Implemented Interfaces:
Comparable<JsInstant>
,JsValue
Represents an immutable instant. An instant is not part of the JSON specification. It is serialized into its string
representation using the ISO-8601 format. A JsInstant and a JsStr are equal if both represent the same date.
For example:
Instant a = Instant.now();
JsStr.of(a.toString()).equals(JsInstant.of(a)) // true
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
int
hashCode()
boolean
Returns true if this JsValue is a JsInstant or a JsString with a value that is a date formatted in ISO-8601.Applies a function to the value of this JsInstant.static JsInstant
Creates a JsInstant from a string representation of an Instant.static JsInstant
Creates a JsInstant from an Instant.Returns this JsValue as a JsPrimitive.toString()
Methods inherited from class jsonvalues.JsPrimitive
isJson, isPrimitive
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface jsonvalues.JsValue
ifNothing, ifNull, isArray, isArray, isBigDec, isBigDec, isBigInt, isBigInt, isBinary, isBool, isDecimal, isDouble, isDouble, isFalse, isInstant, isInt, isInt, isIntegral, isJson, isLong, isLong, isNothing, isNotNothing, isNotNull, isNotNumber, isNull, isNumber, isObj, isObj, isSameType, isStr, isStr, isTrue, toJsArray, toJsBigDec, toJsBigInt, toJsBinary, toJsBool, toJsDouble, toJsInstant, toJsInt, toJsLong, toJsNumber, toJsObj, toJson, toJsStr
-
Field Details
-
prism
Prism between the sum type JsValue and JsInstant. -
value
-
-
Method Details
-
of
Creates a JsInstant from an Instant.- Parameters:
instant
- the Instant to create the JsInstant from.- Returns:
- a JsInstant representing the given Instant.
-
of
Creates a JsInstant from a string representation of an Instant.- Parameters:
instant
- the string representation of an Instant to create the JsInstant from.- Returns:
- a JsInstant representing the parsed Instant.
-
map
Applies a function to the value of this JsInstant.- Parameters:
fn
- the function to apply.- Returns:
- a new JsInstant with the result of applying the function to the value.
-
toJsPrimitive
Description copied from interface:JsValue
Returns this JsValue as a JsPrimitive.- Specified by:
toJsPrimitive
in interfaceJsValue
- Returns:
- This JsValue as a JsPrimitive.
-
isInstant
public boolean isInstant()Description copied from interface:JsValue
Returns true if this JsValue is a JsInstant or a JsString with a value that is a date formatted in ISO-8601. -
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<JsInstant>
-