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

  • Home
  • SEARCH
  • 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 8413383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:54:54+00:00 2026-06-10T00:54:54+00:00

I want to convert the current date to integer value. By default, it returns

  • 0

I want to convert the current date to integer value. By default, it returns long. When I try to convert long to integer, and afterwards I convert the integer value to date, means it shows 1970’s date,

 int i = (int) new Date().getTime();
 System.out.println("Integer : " + i);
 System.out.println("Long : "+ new Date().getTime());
 System.out.println("Long date : " + new Date(new Date().getTime()));
 System.out.println("Int Date : " + new Date(i));

the output as follows:

Integer : 1292838124
Long : 1345617601771
Long date : Wed Aug 22 12:10:01 IST 2012
Int Date : Fri Jan 16 04:37:18 IST 1970

Any one please help me out, how to convert current date to integer(10 digit number)?

  • 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-10T00:54:54+00:00Added an answer on June 10, 2026 at 12:54 am

    The issue is that an Integer is not large enough to store a current date, you need to use a Long.

    The date is stored internally as the number of milliseconds since 1/1/1970.

    The maximum Integer value is 2147483648, whereas the number of milliseconds since 1970 is currently in the order of 1345618537869

    Putting the maximum integer value into a date yields Monday 26th January 1970.

    Edit: Code to display division by 1000 as per comment below:

        int i = (int) (new Date().getTime()/1000);
        System.out.println("Integer : " + i);
        System.out.println("Long : "+ new Date().getTime());
        System.out.println("Long date : " + new Date(new Date().getTime()));
        System.out.println("Int Date : " + new Date(((long)i)*1000L));
    
    Integer : 1345619256
    Long : 1345619256308
    Long date : Wed Aug 22 16:37:36 CST 2012
    Int Date : Wed Aug 22 16:37:36 CST 2012
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert a pointer *int to its real value int , in
I want convert string value into date in my project because I am fetching
I want to convert NSString to NSDate but UIPickerView shows current datedatePicker=[[UIDatePicker alloc]init]; datePicker.userInteractionEnabled=YES;
I want to convert mouse's current X and Y coordinates into the 3D space
In my current project, I want to convert List<String> to RegionLabel Object. For instance,
Can I convert iso date to milliseconds? for example I want to convert this
I've got a simple query where I want to put the current date var
I want to convert a date string to a date object in jQuery, and
I want to get the current date (full date with precision to seconds), and
I need to convert my current date which has the format: MM|dd|yy --- 12|09|11

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.