Created
April 12, 2014 19:52
-
-
Save Vloz/10553552 to your computer and use it in GitHub Desktop.
Here is a dateinput polymer filter to convert its value to a DateTime.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DateTimeFromDateInput extends Transformer<String,DateTime>{ | |
String forward(DateTime d){ | |
String s = d.toString(); | |
return s.substring(0,s.lastIndexOf(' ')); | |
} | |
DateTime reverse(String s) { | |
try{ | |
return DateTime.parse(s); | |
}on Exception { | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment