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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:45:33+00:00 2026-05-18T00:45:33+00:00

I’ve been searching all over and just can’t find a explanation or reason why

  • 0

I’ve been searching all over and just can’t find a explanation or reason why this is happening but the parse(String) method of DateFormat just isn’t parsing my String correctly.

I’m trying to parse a String into the date format that is used for HTTP headers and got as far as getting the String on its own such as:

Thu, 11 Nov 2010 18:34:22 GMT

Which is in the format:

E, d MMM yyyy HH:mm:ss z

But when I use df.parse(dateStr); this is what I get out of it:

Thu Nov 11 18:34:22 GMT 2010

Which is nothing like what I wanted, why is the year now after the GMT? Why is there no comma anymore? And why is the date after the month?

I’m completely confused about this now and can’t find a solution but I really need the date to be in that format. Is the comma messing things up? or the colons?

Thanks for your time,

Infinitifizz

P.S.

Forgot to mention this but I’ve tried dateformat.setLenient(false) and it makes no difference.

P.P.S

I’m trying to do this to compare the dates with date1.before(date2) and after() etc to see if one is newer than the other but I can’t do this because the parsing isn’t working.

Even though they look the same but just the format is different, they are not the same because after calling getTime() on both of them (When I have provided 2 identical dates) the longs are not the same. As in the date is:

Thu, 11 Nov 2010 19:38:52 GMT for a lastModified() on a File

If I input the String “Thu, 11 Nov 2010 19:38:52 GMT” and then compare their longs once converting the string to a date using parse() and then calling getTime() on that date I get:

lastModified = 1289504332671
fromString = 1289504332000

It is only the last 3 digits that are different, does this have any significance?

Thanks again for your time and sorry I didn’t put this bit in first,

Infinitifizz

  • 1 1 Answer
  • 1 View
  • 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-18T00:45:34+00:00Added an answer on May 18, 2026 at 12:45 am

    The result format is the default format of Date#toString() (click link to see the javadoc). You’re apparently doing a System.out.println(date). You would like to use SimpleDateFormat#format() instead with another pattern to format it in the desired format. E.g.

    String newDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
    

    Update: You shouldn’t care about the format when using Date. You should only care about the format at that point when Date is to be converted (displayed) as String. As to the difference in timestamps, the Date uses millisecond precision for the timestamp while HTTP header uses second precision. You’d like to divide the timestamps by 1000 before comparing.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
Does anyone know how can I replace this 2 symbol below from the string
I have a jquery bug and I've been looking for hours now, I can't
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.