11
Locale ptBR = new Locale("pt", "BR");
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyy", ptBR);
SimpleDateFormat iso = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sssZ");
GregorianCalendar calendar = new GregorianCalendar(ptBR);
String data = "31/12/1900";
calendar.setTime(sdf.parse(data));
iso.setTimeZone(calendar.getTimeZone());
System.out.println(iso.format(calendar.getTime()));
Exit: 1900-12-31T00:00:00.000-0306
Can anyone explain to me why the GMT returns -0306 instead of -0300?
Go see your computer created a spindle just for him :) Or you gave him cachaça :) I have no idea if this can happen in "normal conditions". I did not reproduce: http://ideone.com/KLgcdr
– Maniero
I reproduced, it may have something to do with the temporal discontinuity, something similar to that
– Math
Daylight saving time? o. õ
– Pablo Almeida
Try with a recent date. If it’s because of Leap-Seconds the difference is to disappear
– Bacco
Jon Skeet to the Rescue! http://stackoverflow.com/a/6841479/916193
– Bacco
@Bacco then this is the Jon Skeet who spoke on chat kkkk
– user28595
@Diegofelipe Here’s a summary of his skills http://meta.stackexchange.com/questions/9134
– Bacco
What is the return of
calendar.getTimeZone()
?– bfavaretto
@bfavaretto the return is
Mon Dec 31 00:00:00 BRT 1900
– Luan Kevin Ferreira
@Bacco with recent dates does not happen.
– Luan Kevin Ferreira
I found that the problem happens until "12/31/1913", after that normalizes.
– Luan Kevin Ferreira
Related: http://www.timeanddate.com/time/change/brazil/recife?year=1913 and http://www.timeanddate.com/time/change/brazil/salvador?year=1913 Except that in other cities of Brazil this does not happen, except that the salvador adjustment was different from the reef. It’s hard to understand...
– Math
@Math I think I got it, see answer (my Skeet day!!!).
– bfavaretto