Scripts should not directly call Java packages

Rama Rao
Tera Contributor

Actually, We directly call Java packages in the script. Is there any other way to call the java packages?

Can any one help me how to call the java packages in other way?

Script : 

function Returnnextstrikedate(strikedon){
var striked = strikedon;
var strikedate = new GlideDateTime(striked);
var tz = Packages.java.util.TimeZone.getTimeZone('Europe/Oslo');
strikedate.setTZ(tz);
var timeZoneOffSet = strikedate.getTZOffset();
strikedate.setNumericValue(strikedate.getNumericValue() + timeZoneOffSet);
var dayOfWeek = strikedate.getDayOfWeek();
var today = new GlideDateTime();
var dayOfWeek1 = today.getDayOfWeek();
var tz2 = Packages.java.util.TimeZone.getTimeZone('Europe/Oslo');
dayOfWeek1.setTZ(tz2);
var timeZoneOffSet2 = dayOfWeek1.getTZOffset();

7 REPLIES 7

Hello Ankur,

I need to get the timezone using packages and we have a number of scripts with direct call packages. So I need to update that script also.

 

Thanks and Regards,

Haribabu Jadda

Hi,

get timezone of whom? user?

Then once you get timezone what needs to be done next?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

The SN Nerd
Giga Sage
Giga Sage

You might be able to find similar functionality in other Scoped classes:

find_real_file.png

https://developer.servicenow.com/dev.do#!/reference/api/rome/server/no-namespace/c_GlideScheduleScop...


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022