Hi!
In a workflow I try to work with some java.util.*-Classes, and get some strange behaviour:
Working with java.util.Random works as expected, I can access methods of the class without problems.
Trying the same with java.util.Calendar or GregorianCalendar does not work: I always get a "Cannot find function ....()" error when calling a mehtod of Calendar / GregorianCalendar!
(See example code below)
What do I miss?
Download the full example-workflow from the attachment...
Regards,
Joerg
The Code:
//ACCESS java.util.Random works as expected
var rnd = new java.util.Random();
//print out all attributes of rnd
for (var i in rnd) {
System.debug("i: " + i );
}
System.debug("rnd: " + rnd);
var rndint = rnd.nextInt();
System.debug("rndint: " + rndint);
//ACCESS java.util.TimeZone works as expected
var ids = java.util.TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
System.debug("ids: " + ids);
var pdt = new java.util.SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
System.debug("pdt: " + pdt);
//ACCESS Constants in java.util.Calendar works as expected
System.debug("APRIL: " + java.util.Calendar.APRIL);
// set up rules for daylight savings time
pdt.setStartRule(java.util.Calendar.APRIL, 1, java.util.Calendar.SUNDAY, 2 * 60 * 60 * 1000);
pdt.setEndRule(java.util.Calendar.OCTOBER, -1, java.util.Calendar.SUNDAY, 2 * 60 * 60 * 1000);
// create a GregorianCalendar with the Pacific Daylight time zone
// and the current date and time
var calendar = new java.util.GregorianCalendar(pdt);
System.debug("calendar: " + calendar);
//(try to) print out all attributes of calendar: shows nothing!?!?!
for ( i in calendar) {
System.debug("i: " + i );
}
System.debug("========");
//create a calender, and set time to yesterday...
var trialTime = new Date((System.getCurrentTime() - (24 * 60 * 60 * 1000)));
System.debug("trialTime: " + trialTime);
calendar.setTime(trialTime);
System.debug("calendar: " + calendar);
// Creating a java.util.Calendar works
var cl = java.util.Calendar.getInstance();
System.debug("cl: " + cl);
//**** ACCESS methods of java.util.calendar does not work!
var test = cl.getFirstDayOfWeek();