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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:23:46+00:00 2026-05-29T10:23:46+00:00

I have this as a string 02/06/2012 1:25 PM EST I want to use

  • 0

I have this as a string 02/06/2012 1:25 PM EST

I want to use SimpleDateFormat to return “Feb” from that data

Here is what I tried

SimpleDateFormat gottenDate = new SimpleDateFormat("MMM");
            String month = "";
            try {
                month = gottenDate.format(gottenDate.parse("02/06/2012 1:25 PM EST"));
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

Unfortunately gottenDate.parse("02/06/2012 1:25 PM EST") gets a parse exception when the SimpleDateFormat documents say it should work.

If I do SimpleDateFormat gottenDate = new SimpleDateFormat("MM"); with two M’s instead of 3, it returns “02” for me, as expected. The documents say that 3 or more M’s should return a textual month. This doesn’t happen, why? And yes, by now I could have made a string array of months and matched them to the numberic month SDF returned for me, but I am curious.

How do I make it work for me, thank you!

  • 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-29T10:23:47+00:00Added an answer on May 29, 2026 at 10:23 am

    Exception is expected in your case:

    SimpleDateFormat gottenDate = new SimpleDateFormat("MMM");
    gottenDate.parse("02/06/2012 1:25 PM EST");
    

    “gottenDate” is set up to parse a string if it matches “MMM” pattern. The following should work:

    SimpleDateFormat gottenDate = new SimpleDateFormat("MMM");
    gottenDate.parse("Feb");
    

    Hopefully you can see what’s going on here.

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

Sidebar

Related Questions

I have this string 2012-06-27 16:17:06 and I want to convert it to GMT
I have this string: var someString = 23/03/2012; and want to replace all the
I have a timedate string in a round-trip data pattern like this: 2012-07-05T11:30:44.1533815Z .
I have this string in php i want to skip the ppattern ------------------------------------------ FROM:Andy;
I have this string: tag:domain.com,2012-10-12:feed/channel/id/335 Im trying to get the last digits from this
I have a date in this string format 02/28/2012 and I want to convert
I have this datetime as string: Thu, 16 Aug 2012 13:17:25 +0200 I want
I have a string that contain date: 2012-05-25 and i wan to convert this
I have a string 2012-09-16 23:59:59 JST I want to convert this date string
I have date time information in this format: String reportDate=2012-04-19 12:32:24; I want to

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.