JodaTime is amicably the best date and time library out there, maybe.
So I am tempted to receive user input from the front end xhtml Calendar widget in JodaTime instance at the backing bean. Therefore I am thinking of using JSF Converter for this job.
Is this wise to do?
At the same time, since I'm using Primefaces component library and I am already receiving a Date object at my backing bean, would providing a custom Converter require me to do this all over again? I.e. convert from String format to Date object, then to JodaTime DateTime object. Can I somehow let the default JSF convert it to Date first?
Just stick to java.util.Date
in the model, view and persistence layer (as all have already builtin support for it and you generally don't need to perform date calculations/manipulations at those layers at all) and use JodaTime in business layer only whenever you need to perform calculations/manipulations based on the java.util.Date
value. This will keep a lot of things simple.
Once you're on Java 8, migrate java.util.Date
to java.time.Local
/ZonedDateTime
. JSF 2.3 will ship with additional Java 8 support in <f:convertDateTime>
. Until then, you'll need to homebrew them as instructed in this answer: How to use java.time.ZonedDateTime / LocalDateTime in p:calendar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With