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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:31:01+00:00 2026-06-11T22:31:01+00:00

When adding 1 year to a Calendar object the first iteration adds zero years,

  • 0

When adding 1 year to a Calendar object the first iteration adds zero years, even though it should add 1. Each subsequent call adds 1 year, as it should. For example:

calendarObject.add(Calendar.YEAR,1); //This actually adds nothing    
calendarObject.add(Calendar.YEAR,1); // now it works.

Note: calendarObject has been set to have a year of 1995 with no other properties set.

  • 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-11T22:31:03+00:00Added an answer on June 11, 2026 at 10:31 pm

    It just works fine.

    import java.util.Calendar;
    
    
    public class CalTest
    {
        public static void main(String[] args)
        {
            Calendar cal = Calendar.getInstance();
    
            cal.set(Calendar.YEAR, 1995);
            System.out.println(cal.get(Calendar.YEAR));
    
            cal.add(Calendar.YEAR, 1);
            System.out.println(cal.get(Calendar.YEAR));
    
            cal.add(Calendar.YEAR, 1);
            System.out.println(cal.get(Calendar.YEAR));
        }
    }
    

    output:

    1995
    1996
    1997
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Time object and would like to find the next/previous month. Adding
I'm trying to create a report that displays for each months of the year
Suggest any Asp.net control for adding date of birth by specifying day,month & year
So I am having a problem with adding a ManyToMany Object to my Absolute
I want to read the single day, month and year, without adding 3 extra
I want to add 1 year to a datetime-type column in every single row
I'm adding the following code to add an overlay $(function () { { $('#overlay').fadeIn('fast',
Adding more and more configurations to my servlet container ( Embedded Jetty in my
Adding more than one child to a WPF StatusBar results in poor layout with
Adding Exceptional Handling is a good practise, but I have a doubt, In our

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.