Scripts should not directly call Java packages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2022 10:29 PM
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2022 12:44 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2022 01:13 AM
Hi,
get timezone of whom? user?
Then once you get timezone what needs to be done next?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2022 12:50 AM
You might be able to find similar functionality in other Scoped classes:
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022