Question

How to check day light savings is OFF or ON in Pega

Hi team,

Do we have a flag or any mechanism to check whether Day Light Savings is OFF or ON.

***Edited by Moderator Marissa to update platform capability tags****

Correct Answer
November 4, 2019 - 3:34pm

Hi @SarbarthaR4428,

Below is the approach you can follow in pega to know for the DayLight on or off. I followed and get the day light status

1) Create an activity and add an local variable as shown below

2) Implement the following steps in the activity

Java step : IsDayLight = java.util.TimeZone.getDefault().inDaylightTime( new Date() );

This api returns true or false. true means ON, false means OFF. You can use following api, if you want to get the day light value based on timezone

 java.util.TimeZone.getTimeZone( "US/Alaska").inDaylightTime( new Date() );

The IsDayLighOn property is truefalse type in PEGA.

Save the activity and run it whenever needed in the application to see the value of the IsDaylightOn property is set to true or false.

I ran it on a button with "Refresh-this-Section and activity" and saw the result

The end result is

Thats It !. Hope this helps !!

Please feel free to reply for any questions,

Thank you,

Regards, Cherb.

 

Comments

Keep up to date on this post and subscribe to comments

Pega
November 4, 2019 - 12:00pm

Hello,

Time zone and Daylight Savings Time conversions

Pega Platform uses the time zones provided by the JVM on which it runs. The JVM typically uses data provided by the Olson TZ database. Details on this database are available from https://www.iana.org/time-zones.

Note: Daylight savings time rules are supplied by Java JDK vendors. In a multinode system, it is important that the same rules are installed on each node. For details of vendor JDK support of daylight savings time and downloads, see the Oracle knowledge base.

Pega
November 4, 2019 - 3:34pm

Hi @SarbarthaR4428,

Below is the approach you can follow in pega to know for the DayLight on or off. I followed and get the day light status

1) Create an activity and add an local variable as shown below

2) Implement the following steps in the activity

Java step : IsDayLight = java.util.TimeZone.getDefault().inDaylightTime( new Date() );

This api returns true or false. true means ON, false means OFF. You can use following api, if you want to get the day light value based on timezone

 java.util.TimeZone.getTimeZone( "US/Alaska").inDaylightTime( new Date() );

The IsDayLighOn property is truefalse type in PEGA.

Save the activity and run it whenever needed in the application to see the value of the IsDaylightOn property is set to true or false.

I ran it on a button with "Refresh-this-Section and activity" and saw the result

The end result is

Thats It !. Hope this helps !!

Please feel free to reply for any questions,

Thank you,

Regards, Cherb.

 

November 6, 2019 - 9:57am
Response to cherb

Can we convert this as a function instead of Activity rule.

Pega
November 6, 2019 - 10:52am
Response to SarbarthaR4428

Yes. Absolutely. That is a java code and functions accept java code. You can convert as a function.

November 8, 2019 - 1:27am

Thank you. I have created a parameterized function. Which is re usable and can be called from any rule

Pega
November 8, 2019 - 10:01am
Response to SarbarthaR4428

Great. The function seems perfect !.

I'm glad to help you to achieve what you are look for !