spice.Platform.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spice-core_3 Show documentation
Show all versions of spice-core_3 Show documentation
Core functionality leveraged and shared by most other sub-projects of YouI.
package spice
import java.text.SimpleDateFormat
import java.util.Locale
object Platform {
def parseHTTPDate(date: String): Option[Long] = {
val parser = new SimpleDateFormat("EEE, dd MMMM yyyy HH:mm:ss zzz", Locale.ENGLISH)
try {
Some(parser.parse(date.replace('-', ' ')).getTime)
} catch {
case t: Throwable =>
scribe.warn(s"Unable to parse date header: $date (${t.getMessage})")
None
}
}
def toHTTPDate(time: Long): String = {
val parser = new SimpleDateFormat("EEE, dd MMMM yyyy HH:mm:ss zzz", Locale.ENGLISH)
parser.format(time)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy