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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:59:01+00:00 2026-05-24T16:59:01+00:00

This question is a duplicate of this question by intention. It seems like the

  • 0

This question is a duplicate of this question by intention. It seems like the older one is “ignored”, while none of the answers there is the answer.

I need to parse a given date with a given date pattern/format.

I have this code, which is supposed to work:

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main
{

    public static void main(String[] args)
    {
        final Date date = string_to_date("EEE MMM dd HH:mm:ss zzz yyyy",
                "Thu Aug 14 16:45:37 UTC 2011");
        System.out.println(date);
    }

    private static Date string_to_date(final String date_format,
            final String textual_date)
    {
        Date ret = null;

        final SimpleDateFormat date_formatter = new SimpleDateFormat(
                date_format);
        try
        {
            ret = date_formatter.parse(textual_date);
        }
        catch (ParseException e)
        {
            e.printStackTrace();
        }

        return ret;
    }
}

For some reason I’m getting this output:

java.text.ParseException: Unparseable date: "Thu Aug 14 16:45:37 UTC 2011"
    at java.text.DateFormat.parse(DateFormat.java:337)
    at Main.string_to_date(Main.java:24)
    at Main.main(Main.java:10)
null

What’s wrong with my date pattern? This seems to be a mystery.

  • 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-24T16:59:02+00:00Added an answer on May 24, 2026 at 4:59 pm

    Your platform default locale is apparently not English. Thu and Aug are English. You need to explicitly specify the Locale as 2nd argument in the constructor of SimpleDateFormat:

    final SimpleDateFormat date_formatter = 
        new SimpleDateFormat(date_format, Locale.ENGLISH); // <--- Look, with locale.
    

    Without it, the platform default locale will be used instead to parse day/month names. You can learn about your platform default locale by Locale#getDefault() the following way:

    System.out.println(Locale.getDefault());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I know this seems like a duplicate question, but don't think it is.
This question is a duplicate of 1042830 , but MonoTouch-specific. Is there a way
Update: This question is a duplicate of Are there any programming languages targeting PHP,
This is basically a duplicate of this question , but the accepted answer was
Not sure if this question is a duplicate in need of removal, but I
Maybe this question is duplicate, but I can not find an answer for my
I am pretty much worried to make a duplicate with this question while more
EDIT: This question is a duplicate of What is the difference between managed and
This question is an exact duplicate of: Why generate long serialVersionUID instead of a
Duplicate of this question . update - This is not an exact duplicate. See

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.