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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:59:39+00:00 2026-06-11T02:59:39+00:00

I have converted some dates to string and stored them in my database using

  • 0

I have converted some dates to string and stored them in my database using

      DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");

they look like this: “12-09-2012 02:33:00” when they come out as strings

I am then trying to retrieve them using

      DateFormat formatter = new SimpleDateFormat("hh:mm:ss"); 

this gives me a parseexception saying that it’s and unparsable date this is the exception message:

java.text.ParseException: Unparseable date: “12-09-2012 02:33:00” (at offset 2)

Here is some code to give a better understanding of what I am doing:

    String start="";
    String slut="";
    DateFormat formatterday = new SimpleDateFormat("hh:mm:ss");

            start=formatterday.format(formatterday.parse(a.startTime));
            slut=formatterday.format(formatterday.parse(a.endTime));  

I have tried sepparating my statements so that I parse first and then format and the error seems to appear during parse.

  • 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-11T02:59:41+00:00Added an answer on June 11, 2026 at 2:59 am

    Simple date format accepts specific pattern, and your string value “12-09-2012 02:33:00”, clearly doesn’t follow given pattern “hh:mm:ss”. In order to convert original date string to date object you need to use original pattern.

    Simple example:

    DateFormat formatter1 = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
    DateFormat formatter2 = new SimpleDateFormat("hh:mm:ss");
    
    String originalDateValue = "12-09-2012 02:33:00";
    Date originalDate = formatter1.parse( originalDateValue );
    
    String shortDateValue = formatter2.format( originalDate );
    Date shortDate = formatter2.parse( shortDateValue );
    
    System.out.println( originalDateValue );
    System.out.println( originalDate );
    
    System.out.println( shortDateValue );
    System.out.println( shortDate );
    

    This will print out:

    12-09-2012 02:33:00
    Wed Sep 12 02:33:00 CEST 2012
    02:33:00
    Thu Jan 01 02:33:00 CET 1970
    

    Notice that shortDate has value from beginning of era -> 1.1.1970.

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

Sidebar

Related Questions

I have to use some dates and times from a legacy database. They are
I have some double values I want to convert to a string with this
I have some files with same name but with different dates. Basically we are
I (unfortunately) have some dates that were saved into varchar columns. These columns contain
I have some code for converting some timestamps stored as strings into datetime objects
I have some Ruby code which takes dates on the command line in the
I'm using Java 7 and Clojure 1.4 for this. I'm writing up some database
I am trying to convert a String value that is stored in a database,for
Is it possible in javascript to convert some date in timestamp ? i have
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded

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.