Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.30 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. val formats = List(DateTimeFormat.forPattern("MM/dd/yyyy"), DateTimeFormat.forPattern("M/d/yyyy"))
  2.  
  3. def date(x: String): Option[DateTime] = {
  4.     formats.find(f => {
  5.         try {
  6.             f.parseDateTime(x)
  7.             true
  8.         } catch {
  9.             case e => false
  10.         }
  11.     })
  12. }