Problems with date again

T

Tivo Escobar

Hi all,

I am having some problems with dates in Java (again).

When an object of type java.util.Date is initialized with a long, this
long means the number of miliseconds since 00:00:00 01/01/1970 GMT.
The problem is that when I initialize a Date object with zero (new
Date(0)), the result is 22:00:00 31/12/1969 BRST. Since I am in Brazil
time zone (GMT-3) and there was no daylight saving time in Brazil in
the years 1969/1970 I was expecting to obtain 21:00:00 31/12/1969 BRT.
It seems a silly issue, but I am having serious problems to integrate
my Java application with a service written in C++.

In other words, Java thinks there was daylight saving time in the
years 1969/1970 in Brazil, while there was not. Do you know from where
Java gets this information? How can I configure it to the correct
parameters? Any suggestions?

Thanks in adavnce,

Tivo
 
R

Roedy Green

I found these tables once just using Funduc Search and replace to look
for timezone names on the JDK.

I found C:\j2sdk1.4.2\jre\lib\zi\America\Sao_Paulo which appears to be
a serialised object representing the timezone rules. I can't find the
corresponding source any more.

The problem may be the generic timezone class is too stupid to
understand that rules change over time.

Consider these fields that make up a TimeZone

public String toString() {
return getClass().getName() +
"[id=" + getID() +
",offset=" + rawOffset +
",dstSavings=" + dstSavings +
",useDaylight=" + useDaylight +
",startYear=" + startYear +
",startMode=" + startMode +
",startMonth=" + startMonth +
",startDay=" + startDay +
",startDayOfWeek=" + startDayOfWeek +
",startTime=" + startTime +
",startTimeMode=" + startTimeMode +
",endMode=" + endMode +
",endMonth=" + endMonth +
",endDay=" + endDay +
",endDayOfWeek=" + endDayOfWeek +
",endTime=" + endTime +
",endTimeMode=" + endTimeMode + ']';
}

Note that all you have is a year when DST was first observed, no
mechanism for changing the rules after that.

Try complaining to Sun that they need a special Timezone for Brazil to
deal with that period. Likely they will create two zone names, rather
than having the one cleverly figure things out.


In the meantime, you could roll your own Timezone class. It of course
could do it properly because it does not have to use use the ZoneInfo
files to create its Brazil timezone.

If you are stuck, I am available to write code for a modest fee.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top