Spring - conversão de data 16/10/2011 (horário de verão) fica no formulário como 15/10/2011

0 respostas
S

Boa tarde!

Não sei aonde estou errando, mas tenho uma data (java.util.Date) que está sendo convertida erroneamente pelo Spring MVC (Spring 3).

Segue debug do Spring:

2011-11-04 16:35:31,952 [http-8080-Processor25] DEBUG org.springframework.core.convert.support.GenericConversionService - Converting value 2010-11-16 of [TypeDescriptor java.util.Date] to [TypeDescriptor java.lang.String] 2011-11-04 16:35:31,952 [http-8080-Processor25] DEBUG org.springframework.core.convert.support.GenericConversionService - Converted to '2010-11-16' 2011-11-04 16:35:31,955 [http-8080-Processor25] DEBUG org.springframework.core.convert.support.GenericConversionService - Converting value Sun Oct 16 00:00:00 BRST 2011 of [TypeDescriptor @javax.validation.constraints.NotNull @org.springframework.format.annotation.DateTimeFormat java.util.Date] to [TypeDescriptor java.lang.String] 2011-11-04 16:35:31,965 [http-8080-Processor25] DEBUG org.springframework.core.convert.support.GenericConversionService - Converting value Sun Oct 16 00:00:00 BRST 2011 of [TypeDescriptor @javax.validation.constraints.NotNull @org.springframework.format.annotation.DateTimeFormat java.util.Date] to [TypeDescriptor java.lang.Long] 2011-11-04 16:35:31,965 [http-8080-Processor25] DEBUG org.springframework.core.convert.support.GenericConversionService - Converted to 1318730400000 2011-11-04 16:35:32,010 [http-8080-Processor25] DEBUG org.springframework.core.convert.support.GenericConversionService - Converted to '2011-10-15'

Tenho que configurar alguma coisa de TimeZone no Spring também? Ele não deveria usar o default?

LOGGER.debug(String.valueOf( TimeZone.getDefault() ));

sun.util.calendar.ZoneInfo[id="America/Sao_Paulo",offset=-10800000,dstSavings=3600000,useDaylight=true,transitions=129,lastRule=java.util.SimpleTimeZone[id=America/Sao_Paulo,offset=-10800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=9,startDay=8,startDayOfWeek=1,startTime=0,startTimeMode=0,endMode=3,endMonth=1,endDay=15,endDayOfWeek=1,endTime=0,endTimeMode=0]]

EDIT
Se eu remover a annotation que manda o formuláro mostrar o valor como uma data ISO (yyyy-MM-dd) ele mostra o valor correto:

@NotNull
//@DateTimeFormat(iso=ISO.DATE)
private Date dataMarcacao;

O formato ISO.DATE não deveria simplismente mudar para yyyy-MM-dd?

Criado 4 de novembro de 2011
Respostas 0
Participantes 1