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

spice.Platform.scala Maven / Gradle / Ivy

There is a newer version: 0.7.2
Show newest version
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