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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:41:59+00:00 2026-05-30T12:41:59+00:00

My program needs to represent this date as a java.sql.date object , but it

  • 0

My program needs to represent this date as a java.sql.date object , but it seems that when I create a new date (using the calendar) and set it to ‘9999-12-31’ and finally convert this java.util.date object to a java.sql.date object, this date is converted to something like ‘000-01-31’.

Calendar calendar = Calendar.getInstance();
calendar.set(9999, 12, 31);
infinityDate = new java.sql.Date(normalizeDate(calendar.getTime()).getTime());

infinityDate should be 31-12-9999
but when my code reaches here :

if(otherDate.equals(infinityDate))
{// Do stuff}

It never goes into the if condition as the infinityDate has for some reason been changed to 31-01-000, even though otherDate is infact ’31-12-9999′.

The fact that otherDate is 31-12-9999 tells me that java can represent this dates , but for some reason , when I construct it using a calendar it changes the date. (otherDate comes from a jdbc statement which fetches data from a database)

This reference date ’31-12-9999′ has been fixed by some client , so it cannot be changed and my program has to be able to compare some incoming date values with this.
Does anyone know why this is happening , I realize that http://en.wikipedia.org/wiki/Year_10,000_problem may be a problem for dates after year 9999 , but I should be safe by a day.

EDIT : The Normalize date method only “normalizes the given date to midnight of that day”

    private static java.util.Date normalizeDate(java.util.Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    date = calendar.getTime();

    return date;
}

But , this issue was appearing before I was normalizing the date , I normalized it in an attempt to fix this.

  • 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-30T12:42:00+00:00Added an answer on May 30, 2026 at 12:42 pm

    Months are zero indexed. Use 11 for December, not 12. This is why you are rolling over the year.

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

Sidebar

Related Questions

I have some Bruker NMR spectra that i am using to create a program
So I have this Java program that I use to munch through several terabytes
My program needs to listen incoming socket connections (lets agree on port 8765), but
I am writing a program that needs to take an array of size n
I have a program that stores it's information in an XML file. This file
I currently have the following array in a Java program, byte[] data = new
The program needs to take in a simple string from the user and display
My program needs to know when a user ejects cd disc. Is there some
My program needs to do 2 things. Extract stuff from a webpage. Do stuff
My program needs to make use of void* in order to transport data or

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.