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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:28:51+00:00 2026-05-23T07:28:51+00:00

I need to parse dates like Thursday, May 29, 2008 1:45 PM for a

  • 0

I need to parse dates like Thursday, May 29, 2008 1:45 PM for a current project and don’t have much time get it done. I realize I can write some custom parser but that would take a while, I’ve tried a few date parsers I’ve found but none are working for this, I would greatly appreciate if anyone has any advice. I mainly just need to capture the month, day and year as integers, like:

int month = 5;
int date = 29;
int year = 2008

thanks for any advice

  • 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-23T07:28:51+00:00Added an answer on May 23, 2026 at 7:28 am

    Use SimpleDateFormat. According to the docs, the pattern of your date string would be "EEEE, MMMM d, yyyy h:mm a". You can create a SimpleDateFormat object using this pattern and use it to parse strings:

    DateFormat dateParser = new SimpleDateFormat("EEEE, MMMM d, yyyy h:mm a");
    Date myDate = dateParser.parse("Thursday, May 29, 2008 1:45 PM");
    

    As BalusC states in the comments, if your code will be used on machines that do not have English set as the primary language, the above snippet will fail. To avoid this, specify English explicitly when constructing the parser.

     DateFormat dateParser = new SimpleDateFormat("EEEE, MMMM d, yyyy h:mm a", Locale.ENGLISH);
    

    To pull individual values out of the date object, you’ll need to construct a Calendar:

    Calendar calendar = Calendar.getInstance(); // or Calendar.getInstance(Locale.ENGLISH);
    calendar.setTime(myDate);
    

    You can then ask it for the values you want.

    int month = calendar.get(Calendar.MONTH);
    int date = calendar.get(Calendar.DATE);
    int year = calendar.get(Calendar.YEAR);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website where I need to parse date/time strings from receipts. These
I need to parse dates like '070126' to '26 Jan 2007'. I thought I
I have this string containing a date I need to parse to get a
I need to parse a string like February 12, 1981 as a Date. I
I have a rather big number of source files that I need parse and
I need to parse a bunch of incoming xml documents, they all have the
I need to parse a String that does not originally have the year set
Perl newbie here. I have a log file that I need to parse out
I've used the localtime function in Perl to get the current date and time
I get a json date from a webservice that i need to parse manualy

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.