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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:16:04+00:00 2026-05-18T08:16:04+00:00

I’m writing a date/time value to an XML file by reading the date from

  • 0

I’m writing a date/time value to an XML file by reading the date from a RAP based UI as a Java Date object, and passing it as an XMLGregorianCalendar object to actual file writing code. The corresponding classes are auto generated and I don’t have control over them. The date I entered was:

03-03-1933:03:03:03.

It got converted to the following string when written in the file:

1933-03-03T03:03:03.161+05:53

Now, when I read the date back to show it in the UI for edit, it appeared there as:

03-03-1933:03:03:23

Note the extra 20 seconds added to the actual seconds value.

Why is this happening? Is it some bug in the API? Any help will be much appreciated!

Relevant code:

1) Converting to XMLGregorianCalendarfrom Date:

GregorianCalendar calendar = new GregorianCalendar(); 
calendar.setTimeInMillis(date.getTime());
XMLGregorianCalendar date2;
date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);

// pass 'date2' to file writing code

2) Converting to Date from XMLGregorianCalendar:

XMLGregorianCalendar cal = getDateFromFile(); // XML date read from file
Date date = cal.toGregorianCalendar().getTime();

// show Date object in UI, dateCtrl and timeCtrl are SWT DateTime objects

GregorianCalendar calendar = new GregorianCalendar();  
calendar.setTime( date );

dateCtrl.setDate( calendar.get( GregorianCalendar.YEAR ),
    calendar.get( GregorianCalendar.MONTH ),
    calendar.get( GregorianCalendar.DAY_OF_MONTH ) );

timeCtrl.setTime( calendar.get( GregorianCalendar.HOUR_OF_DAY ),
    calendar.get( GregorianCalendar.MINUTE ),
    calendar.get( GregorianCalendar.SECOND) );
  • 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-18T08:16:04+00:00Added an answer on May 18, 2026 at 8:16 am

    Prior to about 1968 there were all sorts of weird offsets, especially in less-developed parts of the world. You don’t say what locale you’re using, but if it’s in India, there was once something called Howra Mean Time that had that offset. I don’t know if it was in effect in 1933 however. You will likely have to download the tz database for your locale and check the configuration for that date.

    EDIT: To verify exactly what is happening, try:

    GregorianCalendar c = new GregorianCalendar();
    TimeZone tz = c.getTimeZone();
    System.out.println(tz);
    
    int tzo = tz.getOffset(date.getTime());
    System.out.println(
          tzo/3600000 + ":" + 
          (tzo/60000)%60 + ":" + 
          (tzo/1000)%60 + "." + 
          tzo%1000);
    

    This will tell you what the system thinks the current timezone is, and the timezone offset in effect on the problematic date in 1933. When I run this in my system I get:

    sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
    -6:0:0.0
    

    HOWEVER, if I change one line:

    GregorianCalendar c = new GregorianCalendar(TimeZone.getTimeZone("IST"));
    

    I then get:

    sun.util.calendar.ZoneInfo[id="IST",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null]
    5:53:20.0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm parsing an XML file, the creators of it stuck in a bunch social
In my XML file chapters tag has more chapter tag.i need to display chapters
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
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 am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from

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.