> Hi,
>
> I also need Timezone information for the timestamps -
No, you don't. Timestamp in Java and DATETIME in SQL are TZ-agnostic. TZ only comes into play when you're parsing a string into a date/timestamp or formatting a date/timestamp into a particular local time string.
I don't understand Timezones, I think.
At the fileserver I create a new Date() - current 'check' time for each file,
and I also retrieve File.lastModified() for each file.
If this File-server has a different TimeZone than the server to which the XML-files with information are sent, isnt it critical to save Timezone info along with date and time?
> I don't understand Timezones, I think.
>
> At the fileserver I create a new Date() - current
> 'check' time for each file,
> and I also retrieve File.lastModified() for each
> file.
Which has no TZ information.
If someone in PDT, someone in EDT, someone in London, and someone in Tokyo create new Date() at the same instant, those Dates' contents will be identical.
> If this File-server has a different TimeZone than the
> server to which the XML-files with information are
> sent, isnt it critical to save Timezone info along
> with date and time?
No. Date just says how many millis have elapsed since a particular point in time. That value is not dependent on TZ.
M millis since the epoch is "right now", regardless of which TZ you're in. Once you factor in the TZ, "right now" might become 12:00 PDT, 14:00 CDT, etc.
So, I can use a timestamp in the xml-files and also use timestamp in db - and when displaying the timestamps, I can use a SimpleDateFormat to format the timestamp with any TimeZone I wish?
Also (thanx again for your patience!), I have the log-file dates. Here I parse out a String like '2007-12-10 22:10:00 0200' for each file. I guess timezone becomes an issue here (0200 for GMT+2 I think) . Im parsing to java.util.Date using SimpleDataFormatter - not sure really what to do with the timezone value? Suggestion for this?
> So, I can use a timestamp in the xml-files
I don't know what this means. If you mean you take a Timestamp's long millis value and shove it in the XML, without regard to TZ, and then extract it in the same way, yes, you can do that.
> and also
> use timestamp in db
Like I said: Create a Timestamp, use PreparedStatement.setTimestamp to push it into a DATETIME column of the DB, and you're golden. You're just marking an instant in time. Like an announcer on global TV is going, "NOW".
> - and when displaying the
> timestamps, I can use a SimpleDateFormat to format
> the timestamp with any TimeZone I wish?
Yup.
> Also (thanx again for your patience!), I have the
> log-file dates. Here I parse out a String like
> '2007-12-10 22:10:00 0200' for each file.
Okay, so you probably want a SimpleDateFormat that knows how to parse the "0200" on the end into appropriate TZ information to give you a TZ-agnostic date.
That is, that's +2 hrs from GMT, right? So when you parse that, you get a java.sql.Date that represents "that instant." It's 10:10 p.m. there, 5:10 p.m. somewhere else, 3:10 a.m. somewhere else, etc., but that doesn't matter. 10:10 p.m. here is exactly the same as 11:10 p.m. in the next TZ. Once I specify 10:10 p.m. here, I've also implicitly stated 00:10 CDT tomorrow in Chicago, etc.
Remember, "now" == X:00 PDT == X+2:00 CDT == X+3:00 EDT == X+ 11:30 or something India TZ, etc.