Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7766141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:20:15+00:00 2026-06-01T15:20:15+00:00

I’m using GWT RPC to send a string containing a date from the client

  • 0

I’m using GWT RPC to send a string containing a date from the client to the server (it has to be this way, because it’s on a request header).

On the server side I parse that string with SimpleDateFormat and make the logic I want.

I’m setting both my cell phone and computer to different time zones, and will use hosted mode and running the test project on tom cat.

Here’s the code:

Client:

DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss Z");
Date date = new Date();

System.out.println("client: " + date.toString());
System.out.println("client: " + dtf.format(date));
builder.setHeader("Date1", dtf.format(date));

Server:

String dateHeader = request.getHeader("Date1");
System.out.println("Server date header from client: " + dateHeader);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");

System.out.println("x = " + sdf.parse(dateHeader));
System.out.println("Timezone = " + df.getTimeZone().getDisplayName());

Result:

Hosted Mode
client: Wed Apr 11 17:29:49 NOVST 2012
client: 2012-04-11 17:29:49 +0700
Server date header from client: 2012-04-11 17:29:49 +0700
x = Wed Apr 11 17:29:49 NOVST 2012


TomCat

  1. Using PC: Client, and server have the same time.

(Can’t see the print of the client, obviously)

Server date header from client: 2012-04-11 17:31:37 +0700
x = Wed Apr 11 17:31:37 NOVST 2012

  1. Cellphone client, has a different from the server.

Server date header from client: 2012-04-11 15:34:35 +0500
x = Wed Apr 11 17:34:35 NOVST 2012

Conclusion:
SimpleDateFormat ignores the Timezone that comes on the string. I don’t want that! I want this to work properly. How can I make this work? Thank you in advanced.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:20:16+00:00Added an answer on June 1, 2026 at 3:20 pm

    SimpleDateFormat doesn’t ignore the timezone, as it has adjusted the time, parsing 15:34:35 +0500 into 17:34:35 NOVST (where NOVST is +0700, the local timezone), it’s just that java.util.Date is only a timestamp from Epoch and has no notion of a timezone (see the javadoc: everything is relative to the local timezone).

    If you want to get the timezone of the client on the server-side, you’ll have to parse the timezone field out of the serialized date (you could split on spaces, keep the last part –the timezone part– and pass it to java.util.TimeZone.getTimeZone() prefixed with GMT).
    Alternatively, you can use JodaTime whose DateTime type keeps track of the timezone info; something like:

    DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss Z");
    
    DateTime dt = fmt.parseDateTime(dateHeader);
    System.out.println("x = " + fmt.print(dt));
    System.out.println("Timezone = " + dt.getZone().toTimeZone().getDisplayName());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.