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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:27:35+00:00 2026-06-15T12:27:35+00:00

I have a string-date 31-Dec, and pattern dd-MMM. And the next code DateFormat formatter

  • 0

I have a string-date “31-Dec”, and pattern “dd-MMM”. And the next code

DateFormat formatter = new SimpleDateFormat(pattern);
formatter.setTimeZone(timeZone);
formatter.parse(input);

generates exception

java.text.ParseException: Unparseable date: "31-Dec"
    at java.text.DateFormat.parse(DateFormat.java:337)....

What did I do wrong?

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-15T12:27:37+00:00Added an answer on June 15, 2026 at 12:27 pm

    One problem could be that your Locale is not english. Try this:

    DateFormat formatter = new SimpleDateFormat("dd-MMM", Locale.ENGLISH);
    try {
        System.out.println(formatter.parse("31-Dec"));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    

    This returns for me:

    Thu Dec 31 00:00:00 CET 1970

    As you are missing a year in your date string, you see that it automatically inserts 1970 as year.

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

Sidebar

Related Questions

The code String strDate = 2010-12-01; SimpleDateFormat sdf = new SimpleDateFormat(yyyy-mm-dd); Date parsedDate =
Possible Duplicate: Parse DateTime with timezone of form PST/CEST/UTC/etc I have a date string
I have a date string and I want to parse it to normal date
I have problem using the NSDateFormatter to parse a date string. I have implemented
I have a c++ code which build an expiration date string for cookie (something
I have a Date object Mon, 03 Dec 2012 and I have a String
I have the following string: HTTP/1.1 200 OK Date: Tue, 06 Dec 2011 11:53:22
String date = new java.text.SimpleDateFormat(MM-dd-yyyy).format(new java.util.date()); upload.uploadfile(192.168.0.210, muruganp, vm4snk, /home/media/Desktop/FTP Upload/+date+_RB.zip, /fileserver/filesbackup/Emac/+date+_RB.zip); uploadfile is
I have a date in string like NSString Date = Dec 21 2011; I
I have a date string of the form '2009/05/13 19:19:30 -0400'. It seems that

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.