B
Big Jim
Hi, I've an app where swing clients run all over the globe and a java server
and sybase DB is in the UK.
The users trype in dates "mm/ydd/yyyy" for a "deal" object and these get
translated to a long, sent to the server and stored in the DB. Any user in
any location can look at the deals in their own client and I want to make
sure they all see the same date, (times aren't important).
I want to store the dates as midnight GMT in the DB (datetime col).
Can anyone give me the standard procedure for this? my current effort ain't
working,
I reckon there's 4 steps: (c = Calendar.getInstance())
In the client:
1.translating from the user entered java.util.Date to the long to send
to the server, currently I'm using:
longDate = d.getTime() + c.get(Calendar.ZONE_OFFSET) +
c.get(Calendar.DST_OFFSET)
2.translating the long sent from the server to the date to display:
date = new date(long + c.get(Calendar.ZONE_OFFSET) +
c.get(Calendar.DST_OFFSET))
On the server:
1.translating the long sent from the client to a date to insert into the
DB:
java.sql.Timestamp stamp = new java.sql.Timestamp(long)
2. translating the date in the DB to a long to send to the client
long = stamp.getTime()
problems:
Sometimes dates go into the DB as midnight and sometimes as 1am, sometimes
certain dates get displayed a day early on the client. Do I need to take
offset/dst into account on the server too?
Cheers for any help,
Richard.
and sybase DB is in the UK.
The users trype in dates "mm/ydd/yyyy" for a "deal" object and these get
translated to a long, sent to the server and stored in the DB. Any user in
any location can look at the deals in their own client and I want to make
sure they all see the same date, (times aren't important).
I want to store the dates as midnight GMT in the DB (datetime col).
Can anyone give me the standard procedure for this? my current effort ain't
working,
I reckon there's 4 steps: (c = Calendar.getInstance())
In the client:
1.translating from the user entered java.util.Date to the long to send
to the server, currently I'm using:
longDate = d.getTime() + c.get(Calendar.ZONE_OFFSET) +
c.get(Calendar.DST_OFFSET)
2.translating the long sent from the server to the date to display:
date = new date(long + c.get(Calendar.ZONE_OFFSET) +
c.get(Calendar.DST_OFFSET))
On the server:
1.translating the long sent from the client to a date to insert into the
DB:
java.sql.Timestamp stamp = new java.sql.Timestamp(long)
2. translating the date in the DB to a long to send to the client
long = stamp.getTime()
problems:
Sometimes dates go into the DB as midnight and sometimes as 1am, sometimes
certain dates get displayed a day early on the client. Do I need to take
offset/dst into account on the server too?
Cheers for any help,
Richard.