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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:30:08+00:00 2026-06-15T22:30:08+00:00

I’ve a doubt about the java Date and SimpleDateFormat . I have an application,

  • 0

I’ve a doubt about the java Date and SimpleDateFormat.

I have an application, which maintains its file creation time in GMT in the format yearMonthDayHourMinute. Currently I am in a different TimeZone (say IST). So I want to do all my processing in the GMT format.

Following snippet shows, how I retrieved convert the date which is stored in my object in to TimeInMillis.

>        1. SimpleDateFormat valueSDF = new SimpleDateFormat("yyyyMMddHHmm");
>        2. valueSDF.setTimeZone(TimeZone.getTimeZone("GMT"));
>        3. Date date = valueSDF.parse("201212060915");
>        4. System.out.println("date.getTime():  "+ date.getTime());   // returns 1354785300000
>        5. String fileCreationTime= Long.toString((date.getTime()/1000));
>        6. System.out.println("time :: "+ fileCreationTime);   // returns 1354785300

The retrieved value in time in millis (step #4) is having an extra three trailing zeros. What my application needs is the result divided by 1000.(step #5)

I am curious to know, why date.getTime() appends more number of zeros to the results.
Stack experts, please share your suggestions !

  • 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-15T22:30:09+00:00Added an answer on June 15, 2026 at 10:30 pm

    I am curious to know, why date.getTime() appends more number of zeros to the results.

    It doesn’t. It gives the number of milliseconds since the Unix epoch. If you need the number of seconds since the Unix epoch of January 1st 1970, midnight UTC, you need to divide by 1000. If you want milliseconds (as you claim) then don’t divide by 1000. That’s all there is to it – it’s behaving exactly as intended.

    It’s not clear why you thinking it’s “adding” three zeroes, but I can assure you that it’s not. Note that 1354785300 milliseconds would only be 376 hours since the Unix epoch…

    The date you’ve given (December 6th 2012, 9:15am in UTC) is 1354785300000 milliseconds since the Unix epoch. Why do you expect a result of 1354785300?

    What my application needs is the result divided by 1000

    That’s incompatible with your claim that it needs milliseconds.

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

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have been unable to fix a problem with Java Unicode and encoding. The
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in

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.