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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:41:31+00:00 2026-05-26T21:41:31+00:00

I am trying to convert a date into milliseconds with the following code: GregorianCalendar

  • 0

I am trying to convert a date into milliseconds with the following code:

    GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
    gc.clear();
    gc.set(1900, 1, 1);

    long left = gc.getTimeInMillis();

I get left=-2206310400000, but when I check here, I should get -2208988800000.

What am I doing wrong?

  • 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-05-26T21:41:31+00:00Added an answer on May 26, 2026 at 9:41 pm

    You’re using 1 for the month number, which means February.

    You mean

    gc.set(1900, 0, 1);
    

    From the docs:

    month – the value used to set the MONTH calendar field. Month value is 0-based. e.g., 0 for January.

    Yes, the Java date/time API is broken. If you’re doing any significant amount of work in dates/times, I’d suggest you use Joda Time instead.

    long left = new DateTime(1900, 1, 1, 0, 0, DateTimeZone.UTC).getMillis();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert string into NSDate using following code. NSString *old =
I'm trying to convert a date string into an age. The string is like:
I'm trying to use strtotime to convert the following date: 07/09/2009 17:01:27 It's the
Trying to convert this c code into MIPS and run it in SPIM. int
I am trying to convert java.util.Date into string as Twenty Sixth of October Nineteen
I am trying to convert a uncommon date format into a standard date. Basically
I'm trying to convert [lastViewedAt] => 1329939559 into the date format YYYY-MM-DD, HH:MM ,
In Ruby I am trying to convert a Date into a format that is
I'm trying to convert a date (date type) into a long. This long should
I'm trying to convert this date format (in PHP): dd/mm/yyyy, for example 18/08/2011, into

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.