Results 1 to 8 of 8

Thread: Dates issue

  1. #1
    gabel8 is offline Member
    Join Date
    Jan 2014
    Posts
    27
    Rep Power
    0

    Default Dates issue

    I have a swing application that uses an application server for its business logic. The tomcat server is located in EST time zone and the swing client is used in many time zones. The issue that is occurring is that on the client, dates are created and then sent to the application server to be compared with dates that are created on the application server. The issue is the time zones are not the same and dates are being changed. For example, on the client, the user would enter a date string of 4/29/15 but when a date object is created and compared on the server, it is getting changed to 4/28/15. I was wondering what the correct way would be to address this issue? Would I set the timezone to EST when the client creates a date object? Any help would be great.

    Thanks in advance.
    Last edited by gabel8; 06-16-2015 at 02:31 PM.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Dates issue

    So how do you test that the date object changes? Dates themselves do not have a timezone, they're only a timestamp.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    gabel8 is offline Member
    Join Date
    Jan 2014
    Posts
    27
    Rep Power
    0

    Default Re: Dates issue

    I am using the SimpleDateFormat and formatting the date to MM/dd/yyyy from the client and the formatted date is sent to the server.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Dates issue

    That doesn't answer my question.

    Let me be specific then: you have a Date in your client and you have a Date in your server; in between that date is transformed into a String format; I wouldn't know why, I would just transmit the timestamp. But whatever the case, at some point you must be translating that String back to a Date object and that is when you realize that it is "different".

    So output the timestamp on the client and output the timestamp on the server - is the timestamp different?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    gabel8 is offline Member
    Join Date
    Jan 2014
    Posts
    27
    Rep Power
    0

    Default Re: Dates issue

    Let me try to be a little clearer with my issue. My client accepts input for dates, when the date is entered, it is formatted using SimpleDateFormat and stored as a Date (I am restricted to store this as a date in the database). Then when processing occurs by the client, this information is sent to the server. On the server, there is some logic that retrieves a date from the database (this also uses the SimpleDateFormat as the client does in the same format) and then compares that date to the ones sent in from the client.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: Dates issue

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Dates issue

    Sigh. I choose to be a child and be done with this now, I'm glad to see the people in the other thread also went the way of timestamps.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    Gotcha is offline Member
    Join Date
    Jun 2015
    Location
    America
    Posts
    29
    Rep Power
    0

    Default Re: Dates issue

    If you want one date and only one date then drop timezones and set it up miliseconds simce 1970. if you want 0ne date from one server make a date server. If you must have one date but you insist on handling it at the client then deal with timezones.. But now it will need lots of checking...

Similar Threads

  1. Integer Dates to String Dates Problem
    By HelpingIsCaring in forum New To Java
    Replies: 32
    Last Post: 08-23-2013, 12:29 AM
  2. Dates sometimes off by a day?
    By saggio in forum Advanced Java
    Replies: 13
    Last Post: 12-08-2010, 04:56 PM
  3. UTC Dates
    By PedroCosta in forum Advanced Java
    Replies: 3
    Last Post: 04-01-2010, 06:08 PM
  4. calculating with dates
    By hannes in forum New To Java
    Replies: 1
    Last Post: 01-14-2010, 08:22 PM
  5. Help with dates
    By bumblyb33 in forum New To Java
    Replies: 1
    Last Post: 02-13-2009, 02:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •