java.util.Calendar calculates wrong date when any duration is added
Hi friends,
I am trying to calculate the date through java.util.Calendar object and getting wrong value. Let me explain the scenario -
Scenario1:
I have taken start date and added some duration to that and expecting a new date which should be calculated as (start date+ duration). The value is as below -
start date = 2012-01-09 (9 January 2012 )
duration = 1year, 1month, 20 days
new date = 2013-02-28 ( 28 February 2013)
*Here new date I am expecting is 2013-03-01 (1 March 2013).
Scenario2:
I have taken another set of values as below -
start date = 2011-02-15 (15 February 2011)
duration = 1year, 1month, 15days
new date = 2012-03-30 (30 March 2012)
*Here new date is as expected.
Scenario1 data is giving me wrong result. Please let me know if any more information is required. Any help will be appriciated. Thanks in advance.
Edited by: user560316 on ९ जनवरी, २०१२ ६:२३ अपराह्न
Edited by: user560316 on ९ जनवरी, २०१२ ६:२४ अपराह्न