Package org.ojalgo.type.context
Class TemporalContext<T extends java.time.temporal.Temporal>
- java.lang.Object
-
- org.ojalgo.type.context.TemporalContext<T>
-
- All Implemented Interfaces:
TypeContext<T>
public final class TemporalContext<T extends java.time.temporal.Temporal> extends java.lang.Object implements TypeContext<T>
An implementation ofTypeContext
that is implemented in terms ofDateTimeFormatter
andTemporalAdjuster
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.time.temporal.TemporalAdjuster
myAdjuster
private java.time.format.DateTimeFormatter
myFormatter
-
Constructor Summary
Constructors Constructor Description TemporalContext(java.time.format.DateTimeFormatter formatter, java.time.temporal.TemporalAdjuster adjuster)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
enforce(T object)
Will force the object to conform to the context's specification.java.lang.String
format(java.lang.Object object)
static <T extends java.time.temporal.Temporal>
TemporalContext<T>of(java.time.format.DateTimeFormatter formatter)
static <T extends java.time.temporal.Temporal>
TemporalContext<T>of(java.time.format.DateTimeFormatter formatter, java.time.temporal.TemporalAdjuster adjuster)
T
parse(java.lang.CharSequence text)
TemporalContext<T>
withAdjuster(java.time.temporal.TemporalAdjuster adjuster)
TemporalContext<T>
withFormatter(java.time.format.DateTimeFormatter formatter)
-
-
-
Method Detail
-
of
public static <T extends java.time.temporal.Temporal> TemporalContext<T> of(java.time.format.DateTimeFormatter formatter)
-
of
public static <T extends java.time.temporal.Temporal> TemporalContext<T> of(java.time.format.DateTimeFormatter formatter, java.time.temporal.TemporalAdjuster adjuster)
-
enforce
public T enforce(T object)
Description copied from interface:TypeContext
Will force the object to conform to the context's specification. The default implementation formats aString
and then parses that back to an object (of the original type).- Specified by:
enforce
in interfaceTypeContext<T extends java.time.temporal.Temporal>
-
format
public java.lang.String format(java.lang.Object object)
- Specified by:
format
in interfaceTypeContext<T extends java.time.temporal.Temporal>
-
parse
public T parse(java.lang.CharSequence text)
- Specified by:
parse
in interfaceTypeContext<T extends java.time.temporal.Temporal>
-
withAdjuster
public TemporalContext<T> withAdjuster(java.time.temporal.TemporalAdjuster adjuster)
-
withFormatter
public TemporalContext<T> withFormatter(java.time.format.DateTimeFormatter formatter)
-
-