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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:53:24+00:00 2026-06-01T15:53:24+00:00

I have below code snippet SimpleDateFormat dateFormat = new SimpleDateFormat( yyyy-MM-dd hh:mm:ss.SSS); String processedContentDate=2012-04-10

  • 0

I have below code snippet

SimpleDateFormat dateFormat = new SimpleDateFormat(
      "yyyy-MM-dd hh:mm:ss.SSS");
 String processedContentDate="2012-04-10 12:53:28.033";   
 java.util.Date parsedDate = dateFormat.parse(processedContentDate);
java.sql.Timestamp timestamp = new java.sql.Timestamp(
 parsedDate.getTime());

I get parsed date as Tue Apr 10 00:53:28 IST 2012 and timestamp as 2012-04-10 00:53:28.033 . i want to get the time exactly as 12:53:28.033(as in my original string)
not 00:53:28.033.
Not getting why 12:53:28 is getting converted to 00:53:28. what should I do to get 12:53:28?

EDIT: After getting the response, I tried this small programme where current time is 14:34:38.899
but at both lines i.e at line 1 and line 2, I got below parsed date
2012-04-10 14:34:38.899
As per reply I should have got 02:34:38.899 at line 1 as date format is yyyy-MM-dd hh:mm:ss.SSS")

    java.util.Date date= new java.util.Date();
    String strDate=date.toString();
    java.util.Date parsedDate;
    java.util.Date parsedDate2;
     SimpleDateFormat dateFormat = new SimpleDateFormat(
     "yyyy-MM-dd hh:mm:ss.SSS");// line 1
     SimpleDateFormat dateFormat2 = new SimpleDateFormat(
     "yyyy-MM-dd HH:mm:ss.SSS");//line 2
     try {
         java.sql.Timestamp timestamp = new java.sql.Timestamp(date.getTime());
          strDate=timestamp.toString();


            parsedDate = dateFormat.parse(strDate);//line1
            parsedDate2 = dateFormat2.parse(strDate);//line2
  • 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-01T15:53:25+00:00Added an answer on June 1, 2026 at 3:53 pm

    Define your dateFormat like that

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    

    HH instead of hh. See SimpleDateFormat

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

Sidebar

Related Questions

Hi I have this code snippet below: Paypal paypal = new Paypal(); paypal.Invoice =
I have this snippet of code below. I want to pass the value of
I have a code snippet as below <CheckBox Name=cb Margin=1,2,1,0 IsChecked={Binding Path=IsManager} IsEnabled=True/> Consider
i have below code snippet in my legacy project DetachedCriteria subCriteria = DetachedCriteria.forClass(Employee.class); subCriteria.setProjection(Projections.distinct(Property.forName
I have the code snippet below in C++ which basically calculates the pi using
In the code snippet below, I only have 1 element in the XML that
Anyone have any idea why CGContextFillPath won't work in the code snippet below? I'm
i have below code snippet. It throws the exception at line 3 but query
i have below code snippet. I am not getting how to change the color
I have a table defined (see code snippet below). How can I add a

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.