You need to sign in to do that
Don't have an account?
Admin Admin 31
Weird behavior of method Date.newInstance
What should be printed for this piece of code?
Date f1 = date.newinstance(2014,19,13); // yyyy, MM, dd for my timezone...meaning the month is invalid
system.debug(f1);
It is printing: 2015-07-13 00:00:00
..meaning it is adding the extra months to the date!!!! it should throw an exception as any language would do!!!
OR...the behavior should be documented in the dev docs.
Date f1 = date.newinstance(2014,19,13); // yyyy, MM, dd for my timezone...meaning the month is invalid
system.debug(f1);
It is printing: 2015-07-13 00:00:00
..meaning it is adding the extra months to the date!!!! it should throw an exception as any language would do!!!
OR...the behavior should be documented in the dev docs.
reference:
https://docs.oracle.com/javase/7/docs/api/java/util/Date.html
"for example, a date may be specified as January 32 and is interpreted as meaning February 1."