I would like to use a Date field in my playOrm mapping. However, if I use
private Date birthDate;
in my bean, it gives me an exception saying this type is not supported.
I would like to use a Date field in my playOrm mapping. However, if I use
private Date birthDate;
in my bean, it gives me an exception saying this type is not supported.
I can add Date if you open an issue. I was thinking of actually throwing an exception when people use Date that says this though instead..
Please use LocalDate, LocalTime or LocalDateTime from joda-time which was supposed to be added in jdk7 but more than likely will end up in jdk8. The reason for this is java.util.Date and Calendar from java are buggy and have lots of known bugs in the jdk bug system.
See this as well Joda Time to be included in Java 7?
If however, you still want to use Date, here is how
Map<Class, Converter> converters = new HashMap<Class, Converter>();
Converter d = new DateConverter();
converters.put(Date.class, d);
Then you need to implement the Converter interface with your DateConverter class and implement the byte[] to Date and Date to byte[] and String to Date and Date to String methods. NOTE: These methods are all called for S-SQL and for converting entities...it all uses the same converters.
The string conversions are VERY important as the command line tool will use them to convert your command line S-SQL to query the objects.
HOWEVER, if you want it built-in to PlayOrm, just open an issue and I can do it pretty quickly BUT I still suggest you use LocalDateTime instead in joda-time as it is more reliable and you can do more with it....after using joda-time quite a bit, it is on-par with C# date apis and way better than the old java stuff.
Dean
I'm not sure what you're asking for, but as stated in the Java API for Date, "As of JDK 1.1, the Calendar
class should be used to convert between dates and time fields and the DateFormat
class should be used to format and parse date strings. The corresponding methods in Date are deprecated."