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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:25:22+00:00 2026-06-15T04:25:22+00:00

I create a calendar object from a string date I receive. Calendar cal =

  • 0

I create a calendar object from a string date I receive.

        Calendar cal = Calendar.getInstance();
    String date = "example Mon, 22 Oct 2012 23:58:31 GMT";
    SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
    sdf.setTimeZone (TimeZone.getTimeZone ("PST"));
    try {
        cal.setTime(sdf.parse(date));  
    } catch (ParseException e) {
        e.printStackTrace();

    }
   System.out.println("date "+sdf.format(cal.getTime()));

This date converts and prints the gmt time to pst with no problem.

I then loop through an array of the elements object and add seconds

int offset = element.getSeconds;
cal.add(Calendar.SECOND, offset);
System.out.println("times cal offset: " + cal.getTime());

This cal now prints the server time (which is eastern time) and not the converted gmt that is printed above. Does something bypass the cal created from the string gmt date when seconds are added?

Thanks!

  • 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-15T04:25:23+00:00Added an answer on June 15, 2026 at 4:25 am

    This because you don’t use SDF with setted GMT timezone for printing in second time.

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

Sidebar

Related Questions

I cannot use Joda. When I try to create a Date or Calendar from
Obviously I could create a Calendar object with the date and use get(DAY) on
I'm using Perl's Calendar module to create a date, and I want to serialize
I have a String representation of a date that I need to create a
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I am trying to create a sharepoint calendar event using client object model. I
I would like to create and add a calendar object plus select elements(comboboxes) for
I want to create a calendar with the following features in picture I want
we are trying to create a calendar function in python. we have created a
I want to create an Event Calendar for my iPhone App. In a first

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.