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 377817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:44:00+00:00 2026-05-12T14:44:00+00:00

I have a JAX-B java web service which I’m using to update a database.

  • 0

I have a JAX-B java web service which I’m using to update a database. Each row in the table that I’m updating is represented by an object similar to below: –

public class Item {
    private String id;
    private Date startDate;
    private Date endDate;

    public Item() { }

    ...

}

This class is being instantiated in a separate program and then passed via SOAP in a message similar to below: –

...

<item>
    <id>D001IAAC030</id>
    <startDate>2009-09-17T00:00:00.000+01:00</startDate>
    <endDate>2009-10-01T00:00:00.000+01:00</endDate>
</item>

...

As you can see, due to BST the UTC time has a +01:00 offset. However, when the object is marshalled on the server (which is on my local machine as well), it reverts to GMT and deducts 1 hour from the dates.

Can you tell me how I can either: –

  1. Set my Glassfish server to right locale so that the dates are recognised as being BST.
  2. Tell me how I can intercept the marshalling at the web service end so that I can set the timezone myself before the date is set.

TIA,

Urf

  • 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-05-12T14:44:00+00:00Added an answer on May 12, 2026 at 2:44 pm

    You just need to remember that a Date object (always) stores date/time as milliseconds since epoch in the UTC/GMT time zone. What trips people up is that the Date.toString() method returns a text representation in the JVM’s default time zone (via an internal Calendar object). (Take a look at JDK source code.)

    So for instance on my machine

    Date now = new Date();
    System.out.println(now.toString());
    System.out.println(now.getTime())
    

    will give

    Fri Oct 02 06:56:24 EST 2009
    1254430584531
    

    The milliseconds number being the actual milliseconds since epoch in the GMT/UTC time zone.

    You should always use Date formatters or Calendar instances when manipulating/using Date objects. For example:

    Date now = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:MM:ss zzz yyyy");
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    System.out.println(now.toString());
    System.out.println(sdf.format(now));
    

    gives

    Fri Oct 02 06:56:24 EST 2009
    Thu Oct 01 20:56:24 UTC 2009
    

    In summary: Always treat a Date object as data only, milliseconds since epoch. (Don’t use any of the Deprecated methods, and don’t use toString() unless you understand what it is displaying.) To display, format, convert (add subtract time etc) date/time always use a Calendar instance or DateFormat implementation and it is hard to go wrong.

    As the Javadoc says for Date:

    ‘Prior to JDK 1.1, the class Date had two additional functions. It allowed the interpretation of dates as year, month, day, hour, minute, and second values. It also allowed the formatting and parsing of date strings. Unfortunately, the API for these functions was not amenable to internationalization. As of JDK 1.1, the Calendar class should be used to convert between dates and time fields and the DateFormat class should be used to format and parse date strings. The corresponding methods in Date are deprecated.’

    Experiment for yourself with Date’s, Calendars and Formatters and read the Javadoc and it will become a little clearer.

    For the first part of your question you shouldn’t need to set the time zone of your Glassfish server to accommodate your data. If you want to store time zone data with your data/time values then use Calendar rather than Date in your objects. Or as I usually do, everything is stored as UTC time (in db and Date instances in objects) and time zones are only used when data is displayed/outputted or parsed. So when your data is received parse it with a DateFormat or equivalent with time zone set to +01:00 (it may pick that up from the time string automatically if it has the time zone attached as you example shows).

    I don’t know specifically about the second part of your question but if the implementation of your web-service end handles Dates correctly and parses them correctly it should handle this without your intervention.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 216k
  • Answers 216k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The overloaded ->* operator is a binary operator (while .*… May 12, 2026 at 11:13 pm
  • Editorial Team
    Editorial Team added an answer There is an undocumented but well known stored procedure sp_msforeachtable:… May 12, 2026 at 11:13 pm
  • Editorial Team
    Editorial Team added an answer you could divide the top and bottom by exp(-x) P(x,y)… May 12, 2026 at 11:13 pm

Related Questions

I have a JAX-B java web service which I'm using to update a database.
Im pretty new to Java Web Services, but I cant find a good explanation
A client is having an issue running java2ws on some of their code, which
WS to make a web service. As parameters I am taking in two strings
Goal Java client for Yahoo's HotJobs Resumé Search REST API . Background I'm used

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.