Skip to content

Commit

Permalink
if only given day, assume GMT
Browse files Browse the repository at this point in the history
  • Loading branch information
squito committed Mar 23, 2015
1 parent 51eaedb commit 25cd894
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.spark.status.api.v1

import java.text.SimpleDateFormat
import java.util.TimeZone
import javax.ws.rs.WebApplicationException
import javax.ws.rs.core.Response
import javax.ws.rs.core.Response.Status
Expand All @@ -40,8 +41,15 @@ private[v1] class SimpleDateParam(val originalValue: String) {
}

private[v1] object SimpleDateParam {
val formats = Seq(
"yyyy-MM-dd'T'HH:mm:ss.SSSz",
"yyyy-MM-dd"
).map { new SimpleDateFormat(_) }

val formats: Seq[SimpleDateFormat] = {

val gmtDay = new SimpleDateFormat("yyyy-MM-dd")
gmtDay.setTimeZone(TimeZone.getTimeZone("GMT"))

Seq(
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz"),
gmtDay
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class SimpleDateParamTest extends FunSuite with Matchers {
test("date parsing") {
new SimpleDateParam("2015-02-20T23:21:17.190GMT").timestamp should be (1424474477190l)
new SimpleDateParam("2015-02-20T17:21:17.190CST").timestamp should be (1424474477190l)
new SimpleDateParam("2015-02-20").timestamp should be (1424412000000l)

new SimpleDateParam("2015-02-20").timestamp should be (1424390400000L) //GMT
}

}

0 comments on commit 25cd894

Please sign in to comment.