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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:15:47+00:00 2026-05-25T10:15:47+00:00

How can I parse the following date in Java from its string representation to

  • 0

How can I parse the following date in Java from its string representation to a java.util.Date?

2011-07-12T16:45:56

I tried the following:

private Date getDateTime(String aDateString) {
    Date result = new java.util.Date();
    SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
    try
    {
        result = sf.parse(aDateString);
    }
    catch (Exception ex)
    {
        Log.e(this.getClass().getName(), "Unable to parse date: " + aDateString);
    }
    return result;
}
  • 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-25T10:15:48+00:00Added an answer on May 25, 2026 at 10:15 am

    You are not using the right date format pattern. The year/month/day separators are clearly wrong, and you need a literal 'T'. Try this:

    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    

    For the record, this is an ISO 8601 combined date and time format.

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

Sidebar

Related Questions

I have the following date string: 2011-09-06T22:02:57-04:00 . The problem is the timezone, -04:00
The following code will parse a String value of 2011-06-19T00:42:01 AND 2011-06-19T12:42:01 as 2011-06-19T00:42:01
How can i parse the following json string without the opening and closing quotes?
I need to format my date (in Java) which is in String format. When
I need help with the following issue. I parse XML and do a XSLT
I have the following XML code that I'm trying to parse, but I'm sure
How can I convert the difference of the current time a given time to
I'm trying to output a calendar object which also contains the time. I've written
I am currently working on my homepage which is entirely supported by a number
I am not an expert on the internals of C# so this question might

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.