# HG changeset patch # User Tomas Zeman # Date 1298019362 -3600 # Node ID b2c3a430fd597444de28a3e6d223f26c01c98a88 # Parent 824fbbce8e65315daf89aae726f7da8e727ea187 lift date-time-converter (Y-m-d format) diff -r 824fbbce8e65 -r b2c3a430fd59 scala/lift/date-time-converter.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scala/lift/date-time-converter.scala Fri Feb 18 09:56:02 2011 +0100 @@ -0,0 +1,19 @@ +package example + +object YmdDateTimeConverter extends DateTimeConverter { + val df = new SimpleDateFormat("yyyy-MM-dd") + val dtf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") + + def formatDateTime(d: Date) = dtf.format(d) + def formatDate(d: Date) = df.format(d) + /** Uses Helpers.hourFormat which includes seconds but not time zone */ + def formatTime(d: Date) = hourFormat.format(d) + + def parseDateTime(s: String) = tryo { dtf.parse(s) } + def parseDate(s: String) = tryo { df.parse(s) } + /** Tries Helpers.hourFormat and Helpers.timeFormat */ + def parseTime(s: String) = + tryo{hourFormat.parse(s)} or tryo{timeFormatter.parse(s)} +} + +// vim: set ts=2 sw=2 et: