Hi,
I have a strange problem when adding a year to a 'leap' date. i.e.
2004/02/29 (yyyy/mm/dd) and wondering if anyone else has experienced
it. Basically J# code gives a different result than C# and Java. Check
out this code:
java.util.Calendar date = java.util.Calendar.getInstance();
date.set(2004, 1, 29, 0, 0, 0); //29th Feb 2004 - a leap day
date.add(java.util.Calendar.YEAR, 1);
System.out.println(date.getTime());
When I compile this under Sun's JDK 1.4.2_06 and execute it (I use
Eclipse platform for Java development), the output I get is:
Mon Feb 28 00:00:00 GMT 2005
When I compile in a J# console application using VS.Net I get:
Tue Mar 01 00:00:00 GMT+00:00 2005
The dates are different! Does anyone know why this could be the case?
To compare, C# code:
DateTime date = new DateTime(2004, 2, 29);
date = date.AddYears(1);
Console.WriteLine("c#: " + date.ToString());
gives:
2/28/2005 12:00:00 AM
which is the same value as the Java compiled output. So clearly this is
a J# problem. Or is it?
Any help or info would be greatly appreciated.
Thanks,
Burt.
Lars-Inge T?nnessen [VJ# MVP] - 25 Feb 2005 19:37 GMT
> So clearly this is a J# problem.
Yes, I agree. It should give the same result as Java. Clearly a problem.
=:o)
Regards,
Lars-Inge T?nnessen
burtr - 26 Feb 2005 01:13 GMT