Re: how to make dates without timezones?
- From: epicwinter <epicwinter@xxxxxxxxxxx>
- Date: Sat, 21 Feb 2009 12:09:56 -0800 (PST)
On Feb 21, 11:35 am, Arne Vajhøj <a...@xxxxxxxxxx> wrote:
epicwinter wrote:
On Feb 21, 8:21 am, Arne Vajhøj <a...@xxxxxxxxxx> wrote:
epicwinter wrote:
In my database I have a lot of date fields that aren't time stamps butThe same time *can* be two different days in two different timezones.
just store dates. The problem is that when i load them into a java
Date it automatically assigns the timezone. The result will be a date
with 0 hours, 0 minutes, 0 seconds and the time zone of the server.
Like 02/20/2009 00:00:00 CST.
My application is a client server app using rmi. When the date is
passed to the client through all of the sudden the time zone which was
auto assigned when the date was populated from the server can change
the actual date. So if on the server I have 02/20/2009 00:00:00 CST
and the client is on pacific time then the date shows as the day
before. Because that date in pacific standard time is 02/19/2009
23:00:00 PST
So is there a way for all my dates to be completely ignorant of time
zones?
The two most obvious solutions for your requirement to have client
show server date are:
- have the server do the formatting and send String instead of DateTime
This would work but I was really hoping to avoid it, it is a pain to
maintain and just kind of kludgy. It seems to me that java should
have a date class without time and timezone. Every database has a
date type and a timestamp type, yet java doesn't support just date
types. What surprises me more is that this doesn't appear to be a
common issue.
None of the classes java.util.Date, java.sql.Date etc. has
timezone - they basically contains number of milliseconds since
1-Jan-1970 00:00:00 in London.
It is all in the formatting !
- have the client format using the servers timezone
I have tried this too. It works in some respects but creates new
issues. There are a few areas where time is pertinent on my
application and in this manner it would always show the client the
wrong time unless they happened to actually be in the same time zone
as the server.
I don't understand that argument.
You can specify timezone for each individual formatting (DateFormat
has a setTimeZone method.
Arne
Arne- I am sorry but I don't understand what you mean by it is just
formatting. In my database i only store a date type that includes
month, day, year. When I load that into a Date class it automatically
assigns the local timezone and i get 02-21-2009 00:00:00 CST or
whatever the time zone is. If that date is then viewed on a client on
PST then it is 02-20-2009 22:00:00 PST. So the date portion shows the
day before.
.
- Follow-Ups:
- Re: how to make dates without timezones?
- From: Lew
- Re: how to make dates without timezones?
- From: Arne Vajhøj
- Re: how to make dates without timezones?
- References:
- how to make dates without timezones?
- From: epicwinter
- Re: how to make dates without timezones?
- From: Arne Vajhøj
- Re: how to make dates without timezones?
- From: epicwinter
- Re: how to make dates without timezones?
- From: Arne Vajhøj
- how to make dates without timezones?
- Prev by Date: Re: how to make dates without timezones?
- Next by Date: Re: How to enable JIT?
- Previous by thread: Re: how to make dates without timezones?
- Next by thread: Re: how to make dates without timezones?
- Index(es):
Relevant Pages
|