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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:06:44+00:00 2026-06-13T23:06:44+00:00

So I am trying to parse a date string in Java. I am getting

  • 0

So I am trying to parse a date string in Java. I am getting the correct hours back but the minutes seem to be out by about 5-10. I am showing my code below along with the input string and the date Objects toString() output.

Any ideas where I am going wrong? This is on Android so I would prefer not to use JodaTime.

DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); 

Date date = sdf.parse(input);

return date;

Input String = 2012-11-07T12:47:05.0581816Z

Date toString() = Wed Nov 07 12:56:46 GMT 2012 (Milliseconds = 1352293006816)

  • 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-13T23:06:44+00:00Added an answer on June 13, 2026 at 11:06 pm

    You are trying to parse a date with microsecond precision as millisecond precision.

    0581816 is the number of milliseconds added to the time 12:47:05, not, as you probably expect, a decimal fraction of a second.

    Since the precision below millisecond cannot be represented by java.util.Date, the simplest option would be to truncate the decimal fraction and adjust the date format, as follows:

    final DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    String input = "2012-11-07T12:47:05.058234234Z";
    input = input.replaceFirst("(?<=\\.\\d{3})\\d+", "");
    System.out.println(input);
    System.out.println(sdf.parse(input));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse a String that represents a date using GMT, but it
I'm trying to parse a (String) date into Date object, but no matter what
Im trying to parse a String thats a date 2012-07-15T20:55:33+00:00, however I keep getting
Hi i am trying to parse a string into a java.sql.date Here is what
I'm trying to parse a string to a date field in an android application
Trying to parse an SQL string and pull out the parameters. Ex: select *
I'm trying to parse a date/time string using DateTime.ParseExact . It works everywhere, except
I am trying to parse a timestamp into a human-readable date string, however, I
I am trying to parse an SQL date string (ISO 9075) and that uses
I'm trying to parse string representation of date. It looks like 20120306 14:21:35 MSK

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.