Adobe acrobat forms javascript object specification User Manual

Page of 64
Acrobat Forms - JavaScript Object Specification
59
var s2 = util.printd("yy/m/d", d);
var s3 = util.printd("mmmm dd, yyyy", d);
var s4 = util.printd("dd-mmm-yyyy", d);
/* print these strings to the console */
console.println("Format mm/dd/yy looks like: " + s1);
console.println("Format yy/m/d looks like: " + s2);
console.println("Format mmmm dd, yyyy looks like: " + s3);
console.println("Format dd-mmm-yyyy looks like: " + s4);
The output of this script would look like:
Format mm/dd/yy looks like: 01/15/99
Format yy/mm/dd looks like: 99/1/15
Format mmmm dd, yyyy looks like: January 15, 1999
Format dd-mmm-yyyy looks like: 15-Jan-1999
Note:
Given the relative closeness of the new millenium and the ever increasing
length of the human lifespan, it is advised to output dates with a four digit
year to avoid ambiguity.
Converting a String to a Date
To convert a string into a Date object the
method of the
is used. It accepts a
format string that it uses as a hint as to the order of the year, month, and day in the input
string.
/* Example of util.scand */
/* Create some strings containing the same date in differing formats. */
var s1 = "03/12/97";
var s2 = "80/06/01";
var s3 = "December 6, 1948";
var s4 = "Saturday 04/11/76";
var s5 = "Tue. 02/01/30";
var s6 = "Friday, Jan. the 15th, 1999";
/* Convert the strings into Date objects using util.scand */
var d1 = util.scand("mm/dd/yy", s1);
var d2 = util.scand("yy/mm/dd", s2);
var d3 = util.scand("mmmm dd, yyyy", s3);
var d4 = util.scand("mm/dd/yy", s4);
var d5 = util.scand("yy/mm/dd", s5);
var d6 = util.scand("mmmm dd, yyyy", s6);
/* Print the dates to the console using util.printd */
console.println(util.printd("mm/dd/yyyy", d1));
console.println(util.printd("mm/dd/yyyy", d2));
console.println(util.printd("mm/dd/yyyy", d3));