GMT returns -0306 instead of -0300, what's the reason?

9
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()));

Output: 1900-12-31T00:00:00.000-0306

Does anyone know why the GMT returns -0306 instead of -0300?

    
asked by anonymous 01.12.2015 / 18:10

2 answers

12

Until 1914, Brazil used the LMT (Local Mean Time) as a time reference . From that year, it began to adopt different time zones, with differences in round hours compared to UTC. The LMT is based on longitude, so there were differences in time fractions from one location to another.

With the regulation of official time zones by decree in 1913 (effective from of 1/1/1914), the small differences between the localities were normalized, as can be seen in the constant table of such decree:

  

Please note that on 1/1/1914 São Paulo time should be corrected at 6m35s. I think that's the difference your code is showing.

    
01.12.2015 / 19:09
-3

Hi @Luan, is the code below for you?

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.sssX");
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()));
    
01.12.2015 / 18:28