Creates a StringCodec instance for java.util.Date
.
Creates a StringCodec instance for java.util.Date
.
scala> import java.text.SimpleDateFormat scala> import java.util.Date scala> val format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz") scala> val codec = StringCodec.dateCodec(format) scala> codec.decode("2016-01-17T22:03:12.012UTC").map(format.format) res1: kantan.codecs.Result[DecodeError, String] = Success(2016-01-17T22:03:12.012UTC) // Encoding example scala> codec.encode(new Date(0)) res2: String = 1970-01-01T00:00:00.000UTC
format used when parsing date values.
Creates a new StringCodec instance from the specified encoder and decoder.
Creates a new StringCodec instance from the specified encoder and decoder.
decoded type.
how to decode to instances of D
.
how to encode instances of D
.
Creates a new StringCodec instance from the specified decoding and encoding functions.
Creates a new StringCodec instance from the specified decoding and encoding functions.
decoded type.
how to decode to instances of D
.
how to encode instances of D
.
Provides instance creation methods.
No instance summoning method is provided - this is by design. Developers should never work with codecs, but with instances of StringEncoder and StringDecoder instead. Codecs are merely meant as a declaration convenience.
Default instances are defined in codecs.