All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.lens.LastModifiedDate.kt Maven / Gradle / Ivy

There is a newer version: 5.41.0.0
Show newest version
package org.http4k.lens

import dev.forkhandles.values.ZonedDateTimeValue
import dev.forkhandles.values.ZonedDateTimeValueFactory
import java.time.ZoneId
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.util.Locale.ENGLISH

val Header.LAST_MODIFIED
    get() = Header.map(LastModified.Companion::parse, LastModified.Companion::show)
        .optional("Last-Modified")

class LastModified private constructor(value: ZonedDateTime) : ZonedDateTimeValue(value) {

    fun toHeaderValue() = LastModified.show(this)

    companion object : ZonedDateTimeValueFactory(
        ::LastModified, fmt = DateTimeFormatter
            .ofPattern("EEE, dd MMM yyyy HH:mm:ss z", ENGLISH)
            .withZone(ZoneId.of("GMT"))
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy