Java8 conversión java.util.Date a java.time.ZonedDateTime
Recibo la siguiente excepción al intentar convertirjava.util.Date
ajava.time.LocalDate
.
java.time.DateTimeException: Unable to obtain ZonedDateTime from TemporalAccessor: 2014-08-19T05:28:16.768Z of type java.time.Instant
El código es el siguiente:
public static Date getNearestQuarterStartDate(Date calculateFromDate){
int[] quaterStartMonths={1,4,7,10};
Date startDate=null;
ZonedDateTime d=ZonedDateTime.from(calculateFromDate.toInstant());
int frmDateMonth=d.getMonth().getValue();
¿Hay algo mal en la forma en que estoy usando elZonedDateTime
¿clase?
Según la documentación, esto debería convertir unjava.util.Date
oponerse aZonedDateTime
. El formato de fecha anterior es Fecha estándar?
¿Tengo que recurrir al tiempo de Joda?
Si alguien pudiera dar alguna sugerencia, sería genial.