I'm currently trying to use two Vaadin DateField
instances to create an interval between two dates.
I'd like to extract the dates picked to a format similar to 2016-04-11. Time and timezone isn't necessary in my case. I'm only interested in the dates.
If I use getValue() I get a string that is formatted like this: Mon Apr 11 00:00:00 CEST 2016. I'm unsure how to use getConvertedValue(), but currently it returns the same thing as getValue().
I have set the DateFormat to "yyyy-MM-dd". This doesn't seem to affect the return value of the get-function though.
I've also tried converting the return value into a Date() (Java-class), but this changes the dates in some weird manor and they never match up to the original.
Main question: How do I extract the date from a DateField to a "yyyy-MM-dd"-format?
According to the documentation, the DateField's value is a java.util.Date and not a java.lang.String (https://vaadin.com/docs/-/part/framework/components/components-datefield.html). If you want to format that Date, you can use the SimpleDateFormat (https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html).