API Gateway Time-Variable has wrong year on 30 and 31 of december


Article ID: 124866


Updated On:


STARTER PACK-7 CA Rapid App Security CA API Gateway


We have a service on the apigw where we must use a date in the following format: 2018-12-30+01:00 (date with timezone). For this we use the api gateway variable ${gateway.time.+01.YYYY-MM-ddX:00}. This actually works fine the whole year, but only on the 30 or 31 of december it does not return the right date. If the unixtime is set to 30.12.2018 it should return 2018-12-30+01:00 but instead it returns 2019-12-30+01:00 (wrong year). We also use another variable which works on all dates: ${gateway.time.CET.iso8601}, here it returns the correct year: 2018-12-30T12:27:23.754+01:00. To recreate it, set your unixtime to the 30 or 31 of december and use the testservice which I attached. Is there any workaround for this bug? 


ENV: 9.3 and 9.4


We found the root cause of this problem. 

This is happening due to the date format string using 'YYYY' instead of 'yyyy' in your policy. 
As per our gateway documentation, our date time format is internally using SimpleDateFormat class from the Java SDK. 

You can check out this docops link (https://docops.ca.com/ca-api-gateway/9-3/en/reference/context-variables/date-and-time-variables )and search for 'SimpleDateFormat.html', it will give you a reference to the JDK documentation. 

Upon referring the same link (https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html) , it was evident that 'Y' and 'y' behaviour is indeed very different 

'y' -> Year 


'Y' -> Week Year 

To understand, as to why both of these return different values. 

Here is a javadoc link (https://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html#week_year) to show the difference. Please search for 'Week Of Year and Week Year' in that doc and notice the line with the following text : 

'A week year is in sync with a WEEK_OF_YEAR cycle. All weeks between the first and last weeks (inclusive) have the same week year value. Therefore, the first and last days of a week year may have different calendar year values.' 

It is due to this, customer was getting different values on using capital 'Y' instead of small 'y'. 


1558537013003dateTest.xml get_app