kantan.csv.java8

Declares kantan.csv.CellDecoder and kantan.csv.CellEncoder instances for java8 date and time types.

Note that the type for default codecs might come as a surprise: the wrapping Exported is used to lower their priority. This is necessary because the standard use case will be to import kantan.csv.java8._, which brings both the instance creation and default instances in scope. Without this type trickery, custom instances and default ones would always clash.

Attributes

Members list

Value members

Concrete methods

override def decoderFrom[D](d: StringDecoder[D]): CellDecoder[D]

Attributes

Definition Classes
TimeDecoderCompanion
Source
package.scala
override def encoderFrom[D](e: StringEncoder[D]): CellEncoder[D]

Attributes

Definition Classes
TimeEncoderCompanion
Source
package.scala

Inherited methods

def defaultInstantDecoder: Decoder[String, Instant, DecodeError, codecs.type]

Creates a Decoder instance using the default format.

Creates a Decoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.defaultInstantDecoder
    |   .decode("2000-01-01T12:00:00.000Z")
res1: StringResult[Instant] = Right(2000-01-01T12:00:00Z)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def defaultInstantEncoder: Encoder[String, Instant, codecs.type]

Creates an Encoder instance using the default format.

Creates an Encoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.defaultInstantEncoder
    |   .encode(Instant.parse("2000-01-01T12:00:00.000Z"))
res1: String = 2000-01-01T12:00:00Z
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def defaultLocalDateDecoder: Decoder[String, LocalDate, DecodeError, codecs.type]

Creates a Decoder instance using the default format.

Creates a Decoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.defaultLocalDateDecoder
    |   .decode("2000-01-01")
res1: StringResult[LocalDate] = Right(2000-01-01)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def defaultLocalDateEncoder: Encoder[String, LocalDate, codecs.type]

Creates an Encoder instance using the default format.

Creates an Encoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.defaultLocalDateEncoder
    |   .encode(LocalDate.of(2000, 1, 1))
res1: String = 2000-01-01
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def defaultLocalDateTimeDecoder: Decoder[String, LocalDateTime, DecodeError, codecs.type]

Creates a Decoder instance using the default format.

Creates a Decoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.defaultLocalDateTimeDecoder
    |   .decode("2000-01-01T12:00:00.000")
res1: StringResult[LocalDateTime] = Right(2000-01-01T12:00)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def defaultLocalDateTimeEncoder: Encoder[String, LocalDateTime, codecs.type]

Creates an Encoder instance using the default format.

Creates an Encoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.defaultLocalDateTimeEncoder
    |   .encode(LocalDateTime.of(2000, 1, 1, 12, 0, 0, 0))
res1: String = 2000-01-01T12:00:00
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def defaultLocalTimeDecoder: Decoder[String, LocalTime, DecodeError, codecs.type]

Creates a Decoder instance using the default format.

Creates a Decoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.defaultLocalTimeDecoder
    |   .decode("12:00:00.000")
res1: StringResult[LocalTime] = Right(12:00)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def defaultLocalTimeEncoder: Encoder[String, LocalTime, codecs.type]

Creates an Encoder instance using the default format.

Creates an Encoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.defaultLocalTimeEncoder
    |   .encode(LocalTime.of(12, 0, 0, 0))
res1: String = 12:00:00
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def defaultOffsetDateTimeDecoder: Decoder[String, OffsetDateTime, DecodeError, codecs.type]

Creates a Decoder instance using the default format.

Creates a Decoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.defaultOffsetDateTimeDecoder
    |   .decode("2000-01-01T12:00:00.000Z")
res1: StringResult[OffsetDateTime] = Right(2000-01-01T12:00Z)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def defaultOffsetDateTimeEncoder: Encoder[String, OffsetDateTime, codecs.type]

Creates an Encoder instance using the default format.

Creates an Encoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.defaultOffsetDateTimeEncoder
    |   .encode(OffsetDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))
res1: String = 2000-01-01T12:00:00Z
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def defaultZonedDateTimeDecoder: Decoder[String, ZonedDateTime, DecodeError, codecs.type]

Creates a Decoder instance using the default format.

Creates a Decoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.defaultZonedDateTimeDecoder
    |   .decode("2000-01-01T12:00:00.000Z")
res1: StringResult[ZonedDateTime] = Right(2000-01-01T12:00Z)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def defaultZonedDateTimeEncoder: Encoder[String, ZonedDateTime, codecs.type]

Creates an Encoder instance using the default format.

Creates an Encoder instance using the default format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.defaultZonedDateTimeEncoder
    |   .encode(ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))
res1: String = 2000-01-01T12:00:00Z
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def instantCodec(format: Format): Codec[String, Instant, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.instantCodec(Format(DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC)))
scala> val encoded = codec.encode(Instant.parse("2000-01-01T12:00:00.000Z"))
res1: String = 2000-01-01T12:00:00Z
scala> codec.decode(encoded)
res2: StringResult[Instant] = Right(2000-01-01T12:00:00Z)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def instantCodec(format: => DateTimeFormatter): Codec[String, Instant, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.instantCodec(DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC))
scala> val encoded = codec.encode(Instant.parse("2000-01-01T12:00:00.000Z"))
res1: String = 2000-01-01T12:00:00Z
scala> codec.decode(encoded)
res2: StringResult[Instant] = Right(2000-01-01T12:00:00Z)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def instantDecoder(format: Format): Decoder[String, Instant, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.instantDecoder(Format(DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC)))
    |   .decode("2000-01-01T12:00:00.000Z")
res1: StringResult[Instant] = Right(2000-01-01T12:00:00Z)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def instantDecoder(format: => DateTimeFormatter): Decoder[String, Instant, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.instantDecoder(DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC))
    |   .decode("2000-01-01T12:00:00.000Z")
res1: StringResult[Instant] = Right(2000-01-01T12:00:00Z)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def instantEncoder(format: Format): Encoder[String, Instant, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.instantEncoder(Format(DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC)))
    |   .encode(Instant.parse("2000-01-01T12:00:00.000Z"))
res1: String = 2000-01-01T12:00:00Z
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def instantEncoder(format: => DateTimeFormatter): Encoder[String, Instant, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.instantEncoder(DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC))
    |   .encode(Instant.parse("2000-01-01T12:00:00.000Z"))
res1: String = 2000-01-01T12:00:00Z
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def localDateCodec(format: Format): Codec[String, LocalDate, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.localDateCodec(fmt"yyyy-MM-dd")
scala> val encoded = codec.encode(LocalDate.of(2000, 1, 1))
res1: String = 2000-01-01
scala> codec.decode(encoded)
res2: StringResult[LocalDate] = Right(2000-01-01)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def localDateCodec(format: => DateTimeFormatter): Codec[String, LocalDate, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.localDateCodec(DateTimeFormatter.ISO_LOCAL_DATE)
scala> val encoded = codec.encode(LocalDate.of(2000, 1, 1))
res1: String = 2000-01-01
scala> codec.decode(encoded)
res2: StringResult[LocalDate] = Right(2000-01-01)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def localDateDecoder(format: Format): Decoder[String, LocalDate, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.localDateDecoder(fmt"yyyy-MM-dd")
    |   .decode("2000-01-01")
res1: StringResult[LocalDate] = Right(2000-01-01)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def localDateDecoder(format: => DateTimeFormatter): Decoder[String, LocalDate, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.localDateDecoder(DateTimeFormatter.ISO_LOCAL_DATE)
    |   .decode("2000-01-01")
res1: StringResult[LocalDate] = Right(2000-01-01)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def localDateEncoder(format: Format): Encoder[String, LocalDate, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.localDateEncoder(fmt"yyyy-MM-dd")
    |   .encode(LocalDate.of(2000, 1, 1))
res1: String = 2000-01-01
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def localDateEncoder(format: => DateTimeFormatter): Encoder[String, LocalDate, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.localDateEncoder(DateTimeFormatter.ISO_LOCAL_DATE)
    |   .encode(LocalDate.of(2000, 1, 1))
res1: String = 2000-01-01
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def localDateTimeCodec(format: Format): Codec[String, LocalDateTime, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.localDateTimeCodec(fmt"yyyy-MM-dd'T'HH:mm:ss.SSS")
scala> val encoded = codec.encode(LocalDateTime.of(2000, 1, 1, 12, 0, 0, 0))
res1: String = 2000-01-01T12:00:00.000
scala> codec.decode(encoded)
res2: StringResult[LocalDateTime] = Right(2000-01-01T12:00)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def localDateTimeCodec(format: => DateTimeFormatter): Codec[String, LocalDateTime, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.localDateTimeCodec(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
scala> val encoded = codec.encode(LocalDateTime.of(2000, 1, 1, 12, 0, 0, 0))
res1: String = 2000-01-01T12:00:00.000
scala> codec.decode(encoded)
res2: StringResult[LocalDateTime] = Right(2000-01-01T12:00)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def localDateTimeDecoder(format: Format): Decoder[String, LocalDateTime, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.localDateTimeDecoder(fmt"yyyy-MM-dd'T'HH:mm:ss.SSS")
    |   .decode("2000-01-01T12:00:00.000")
res1: StringResult[LocalDateTime] = Right(2000-01-01T12:00)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def localDateTimeDecoder(format: => DateTimeFormatter): Decoder[String, LocalDateTime, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.localDateTimeDecoder(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
    |   .decode("2000-01-01T12:00:00.000")
res1: StringResult[LocalDateTime] = Right(2000-01-01T12:00)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def localDateTimeEncoder(format: Format): Encoder[String, LocalDateTime, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.localDateTimeEncoder(fmt"yyyy-MM-dd'T'HH:mm:ss.SSS")
    |   .encode(LocalDateTime.of(2000, 1, 1, 12, 0, 0, 0))
res1: String = 2000-01-01T12:00:00.000
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def localDateTimeEncoder(format: => DateTimeFormatter): Encoder[String, LocalDateTime, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.localDateTimeEncoder(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
    |   .encode(LocalDateTime.of(2000, 1, 1, 12, 0, 0, 0))
res1: String = 2000-01-01T12:00:00
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def localTimeCodec(format: Format): Codec[String, LocalTime, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.localTimeCodec(fmt"HH:mm:ss.SSS")
scala> val encoded = codec.encode(LocalTime.of(12, 0, 0, 0))
res1: String = 12:00:00.000
scala> codec.decode(encoded)
res2: StringResult[LocalTime] = Right(12:00)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def localTimeCodec(format: => DateTimeFormatter): Codec[String, LocalTime, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.localTimeCodec(DateTimeFormatter.ISO_LOCAL_TIME)
scala> val encoded = codec.encode(LocalTime.of(12, 0, 0, 0))
res1: String = 12:00:00.000
scala> codec.decode(encoded)
res2: StringResult[LocalTime] = Right(12:00)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def localTimeDecoder(format: Format): Decoder[String, LocalTime, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.localTimeDecoder(fmt"HH:mm:ss.SSS")
    |   .decode("12:00:00.000")
res1: StringResult[LocalTime] = Right(12:00)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def localTimeDecoder(format: => DateTimeFormatter): Decoder[String, LocalTime, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.localTimeDecoder(DateTimeFormatter.ISO_LOCAL_TIME)
    |   .decode("12:00:00.000")
res1: StringResult[LocalTime] = Right(12:00)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def localTimeEncoder(format: Format): Encoder[String, LocalTime, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.localTimeEncoder(fmt"HH:mm:ss.SSS")
    |   .encode(LocalTime.of(12, 0, 0, 0))
res1: String = 12:00:00.000
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def localTimeEncoder(format: => DateTimeFormatter): Encoder[String, LocalTime, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.localTimeEncoder(DateTimeFormatter.ISO_LOCAL_TIME)
    |   .encode(LocalTime.of(12, 0, 0, 0))
res1: String = 12:00:00
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def offsetDateTimeCodec(format: Format): Codec[String, OffsetDateTime, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.offsetDateTimeCodec(fmt"yyyy-MM-dd'T'HH:mm:ss.SSSXX")
scala> val encoded = codec.encode(OffsetDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))
res1: String = 2000-01-01T12:00:00.000Z
scala> codec.decode(encoded)
res2: StringResult[OffsetDateTime] = Right(2000-01-01T12:00Z)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def offsetDateTimeCodec(format: => DateTimeFormatter): Codec[String, OffsetDateTime, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.offsetDateTimeCodec(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
scala> val encoded = codec.encode(OffsetDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))
res1: String = 2000-01-01T12:00:00.000Z
scala> codec.decode(encoded)
res2: StringResult[OffsetDateTime] = Right(2000-01-01T12:00Z)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def offsetDateTimeDecoder(format: Format): Decoder[String, OffsetDateTime, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.offsetDateTimeDecoder(fmt"yyyy-MM-dd'T'HH:mm:ss.SSSXX")
    |   .decode("2000-01-01T12:00:00.000Z")
res1: StringResult[OffsetDateTime] = Right(2000-01-01T12:00Z)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def offsetDateTimeDecoder(format: => DateTimeFormatter): Decoder[String, OffsetDateTime, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.offsetDateTimeDecoder(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
    |   .decode("2000-01-01T12:00:00.000Z")
res1: StringResult[OffsetDateTime] = Right(2000-01-01T12:00Z)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def offsetDateTimeEncoder(format: Format): Encoder[String, OffsetDateTime, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.offsetDateTimeEncoder(fmt"yyyy-MM-dd'T'HH:mm:ss.SSSXX")
    |   .encode(OffsetDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))
res1: String = 2000-01-01T12:00:00.000Z
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def offsetDateTimeEncoder(format: => DateTimeFormatter): Encoder[String, OffsetDateTime, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.offsetDateTimeEncoder(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
    |   .encode(OffsetDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))
res1: String = 2000-01-01T12:00:00Z
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def zonedDateTimeCodec(format: Format): Codec[String, ZonedDateTime, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.zonedDateTimeCodec(fmt"yyyy-MM-dd'T'HH:mm:ss.SSSVV")
scala> val encoded = codec.encode(ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))
res1: String = 2000-01-01T12:00:00.000Z
scala> codec.decode(encoded)
res2: StringResult[ZonedDateTime] = Right(2000-01-01T12:00Z)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def zonedDateTimeCodec(format: => DateTimeFormatter): Codec[String, ZonedDateTime, DecodeError, codecs.type]

Creates a Codec instance that uses the specified format.

Creates a Codec instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeCodecCompanion[String, DecodeError, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> val codec = Foo.zonedDateTimeCodec(DateTimeFormatter.ISO_ZONED_DATE_TIME)
scala> val encoded = codec.encode(ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))
res1: String = 2000-01-01T12:00:00.000Z
scala> codec.decode(encoded)
res2: StringResult[ZonedDateTime] = Right(2000-01-01T12:00Z)
Inherited from:
TimeCodecCompanion
Source
TimeCodecCompanion.scala
def zonedDateTimeDecoder(format: Format): Decoder[String, ZonedDateTime, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.zonedDateTimeDecoder(fmt"yyyy-MM-dd'T'HH:mm:ss.SSSVV")
    |   .decode("2000-01-01T12:00:00.000Z")
res1: StringResult[ZonedDateTime] = Right(2000-01-01T12:00Z)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def zonedDateTimeDecoder(format: => DateTimeFormatter): Decoder[String, ZonedDateTime, DecodeError, codecs.type]

Creates a Decoder instance that uses the specified format.

Creates a Decoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeDecoderCompanion[String, DecodeError, codecs.type] {
    |   override def decoderFrom[D](d: StringDecoder[D]) = d
    | }
scala> Foo.zonedDateTimeDecoder(DateTimeFormatter.ISO_ZONED_DATE_TIME)
    |   .decode("2000-01-01T12:00:00.000Z")
res1: StringResult[ZonedDateTime] = Right(2000-01-01T12:00Z)
Inherited from:
TimeDecoderCompanion
Source
TimeDecoderCompanion.scala
def zonedDateTimeEncoder(format: Format): Encoder[String, ZonedDateTime, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.zonedDateTimeEncoder(fmt"yyyy-MM-dd'T'HH:mm:ss.SSSVV")
    |   .encode(ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))
res1: String = 2000-01-01T12:00:00.000Z
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala
def zonedDateTimeEncoder(format: => DateTimeFormatter): Encoder[String, ZonedDateTime, codecs.type]

Creates an Encoder instance that uses the specified format.

Creates an Encoder instance that uses the specified format.

Attributes

Example
scala> import java.time._, format._
scala> import kantan.codecs.strings._
scala> object Foo extends TimeEncoderCompanion[String, codecs.type] {
    |   override def encoderFrom[D](e: StringEncoder[D]) = e
    | }
scala> Foo.zonedDateTimeEncoder(DateTimeFormatter.ISO_ZONED_DATE_TIME)
    |   .encode(ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))
res1: String = 2000-01-01T12:00:00Z
Inherited from:
TimeEncoderCompanion
Source
TimeEncoderCompanion.scala

Extensions

Inherited extensions

extension (inline sc: StringContext)
inline def fmt(args: Any*): Format

Attributes

Inherited from:
ToFormatLiteral
Source
FormatLiteral.scala

Implicits

Implicits

implicit val defaultInstantCellDecoder: Exported[CellDecoder[Instant]]

Attributes

Source
package.scala
implicit val defaultInstantCellEncoder: Exported[CellEncoder[Instant]]

Attributes

Source
package.scala
implicit val defaultLocalDateCellDecoder: Exported[CellDecoder[LocalDate]]

Attributes

Source
package.scala
implicit val defaultLocalDateCellEncoder: Exported[CellEncoder[LocalDate]]

Attributes

Source
package.scala
implicit val defaultLocalDateTimeCellDecoder: Exported[CellDecoder[LocalDateTime]]

Attributes

Source
package.scala
implicit val defaultLocalDateTimeCellEncoder: Exported[CellEncoder[LocalDateTime]]

Attributes

Source
package.scala
implicit val defaultLocalTimeCellDecoder: Exported[CellDecoder[LocalTime]]

Attributes

Source
package.scala
implicit val defaultLocalTimeCellEncoder: Exported[CellEncoder[LocalTime]]

Attributes

Source
package.scala
implicit val defaultOffsetDateTimeCellDecoder: Exported[CellDecoder[OffsetDateTime]]

Attributes

Source
package.scala
implicit val defaultOffsetDateTimeCellEncoder: Exported[CellEncoder[OffsetDateTime]]

Attributes

Source
package.scala
implicit val defaultZonedDateTimeCellDecoder: Exported[CellDecoder[ZonedDateTime]]

Attributes

Source
package.scala
implicit val defaultZonedDateTimeCellEncoder: Exported[CellEncoder[ZonedDateTime]]

Attributes

Source
package.scala