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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:04:03+00:00 2026-05-27T20:04:03+00:00

to get the current date and time final Calendar c = Calendar.getInstance(); mYear =

  • 0

to get the current date and time

final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);

to create current date object

Date toDate;
     toDate.setYear(mYear);
     toDate.setMonth(mMonth);
     toDate.setDate(mDay);



Date endDate = toDate;

when printing endDate object I got

Mon Jan 01 13:11:00 GMT+03:00 3912

why ?

  • 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-27T20:04:04+00:00Added an answer on May 27, 2026 at 8:04 pm

    From Date.setYear(int) description: Sets the gregorian calendar year since 1900 for this Date object. Thus, 1900 + 2012 = 3912.

    But calendar.get(Calendar.YEAR) returns exact year number 2012. So this inconsistency of API causes your issue. But anyway Date.setYear(int) is deprecated, thus, it is better to use Calendar object for date calculations.

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

Sidebar

Related Questions

I want to know the current Date and Time. The code Calendar.getInstance(); represents a
I've used the localtime function in Perl to get the current date and time
I want to store the current date & time which can be get by
Possible Duplicate: How to get the current date and time of your timezone in
My Android app requires to get the current date and time from Internet .
I want to get the current date (day, mon and year). I found out
I would like to get the current date/time stamp of the server or client
Is there a way to get current date and time in Yahoo Pipes? I
I am having a quite annoying problem. I want to get the current date/time
How do I get the current date and time in Java? I am looking

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.