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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:02:27+00:00 2026-06-11T21:02:27+00:00

I am trying to convert a String DateTime value which is present in a

  • 0

I am trying to convert a String DateTime value which is present in a flat file as a Date object after parsing the flat file in my code.

I have written the code to do that but when I format the date its always giving me a date more than 1 day for the specified value, some times it’s adding 5:30.

Below is the code for that:

    DateFormat f = new SimpleDateFormat("EEE MMM dd HH:mm:ss zz yyyy");
    Date date = f.parse("Tue Aug 23 20:00:03 PDT 2011");
    System.out.println("---date----" + date);

The output for the above is

    ---date----Wed Aug 24 08:30:03 IST 2011  

Can you please let me know whats the issue here. Is there a problem in the pattern that I am using in the SimplaDateFormat class or is there a problem with the code.
I have been scratching my head on this for a long time now.

  • 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-11T21:02:28+00:00Added an answer on June 11, 2026 at 9:02 pm

    Your system timezone is different. The output is showing IST – or Indian Standard Time, which is an 12.5h difference from PDT. The code is properly parsing the given date which is PDT (UTC -7) and printing out IST (UTC +5h30).

    Java stores Dates as UTC dates. So when you parse the PDT date, Java will convert it to UTC and store it internally as a UTC timestamp. When you print, if you do not specify the timezone, it will default to the system timezone, which in your case would appear to be IST.

    To specify an exact timezone, specify it in the SimpleDateFormat:

    DateFormat f = new SimpleDateFormat("EEE MMM dd HH:mm:ss zz yyyy");
    f.setTimeZone(TimeZone.getTimeZone("PDT"));
    Date date = f.parse("Tue Aug 23 20:00:03 PDT 2011");
    System.out.println("---date----" + f.format(date));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert a string into date time format. DateTime.Parse(tempfrmBankDetails.dgvBankDetails.SelectedRows[0].Cells[PaymentDate].Value.ToString(),null); This is
I am trying to convert varchar date value to datetime format. Showing error select
I am trying to convert the following string to a DateTime value in c#:
I have been trying to convert between timezones a given date and time. Code
I am trying to convert my string formatted value to date type with format
I am trying to convert DateTime object to string using formatting but due to
How can I convert a string 08:00 to a DateTime datatype? Im trying to
I am trying to convert string to class name. My code is: app.actNum =
I am using this code for on android just trying to convert string to
I'm trying to convert a String to a byte array which has 2 different

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.