public java . util . Date getDateWithZone ( ZoneId timezone ) { LocalDate pickerDate = parentDatePicker . getDate ( ) ; if ( pickerDate == null || timezone == null ) { return null ; } Instant instant = pickerDate . atStartOfDay ( timezone ) . toInstant ( ) ; // for backport: java.util.Date javaUtilDate = DateTimeUtils.toDate(instant); // for java.time: java.util.Date javaUtilDate = java.util.Date.from(instant); // This function was created to be compatible with both libraries. java . util . Date javaUtilDate = getJavaUtilDateFromInstant ( instant ) ; return javaUtilDate ; }
getDateWithZone Returns the date picker value as a java . util . Date that was created using the specified time zone or returns null . This will return null if either the date picker has no value or if the supplied time zone was null .