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

  • Home
  • SEARCH
  • 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 8812971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:43:44+00:00 2026-06-14T03:43:44+00:00

I try to parse a date in the format YYYY-MM-DD HH:mm:ss String now =

  • 0

I try to parse a date in the format YYYY-MM-DD HH:mm:ss

String now = "2012-11-02 12:02:00";
DateFormat formatter;
formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
Date date_temp = (Date) formatter.parse(now.toString());
System.out.println("output: " + date_temp);

It gives me following exception

java.text.ParseException: Unparseable date: "2012-11-02 12:02:00"
  • 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-14T03:43:45+00:00Added an answer on June 14, 2026 at 3:43 am

    Well yes, you’ve created a formatted with one format (“EEE MMM dd HH:mm:ss z yyyy”) and then given it a string in a completely different format to parse. Why did you think that would work? Try this:

    // Locale specified to avoid any cultural differences. You may also
    // want to specify the time zone.
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
                                                Locale.US);
    Date date = formatter.parse(now);
    

    Note that the parsed Date does not know anything about formatting – the result of calling toString() (as you’re doing implicitly here) is always just the default format, in the JRE default time zone. If you want to print it out with a particular format, use SimpleDateFormat again.

    Also note that I’ve combined declaration and initialization for the variable. Prefer that over declaring a variable in one line and giving it an initial value later.

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

Sidebar

Related Questions

This code: SimpleDateFormat format = new SimpleDateFormat(yyyy-MM-DD_HH-mm-ss); Date date=null; try { date = format.parse(2012-07-04_13-42-03);
I have the following DateFormat dformat = new SimpleDateFormat(yyyy-M-d); dformat.setLenient(false); Date cin = dformat.parse(cinDate);
How to parse date string with this format (Ex: 2012-04-12T14:23:23). I try with this
In my app you set the date/time with date/timePickers. SimpleDateFormat formatter = new SimpleDateFormat(yyyy-MM-dd
I want the date format as dd-MMM-yyyy. My code is: String v_date_str=Sun Mar 06
please consider the following snippet: SimpleDateFormat parser = new SimpleDateFormat(MMdd); parser.setLenient(false); try { Date
I need to parse a date from input string using date pattern yyyy-MM-dd, and
I have a string that contains a date, in the following format: dd-mm-yyyy with
I have a code returning me a string (HH:mm). SimpleDateFormat curFormater = new SimpleDateFormat(yyyy-MM-dd
I am trying to convert a string to proper date format using Java's SimpleDateFormat

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.