Layer 7 API Management

Expand all | Collapse all

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

Jump to Best Answer
  • 1.  API Gateway Time-Variable has wrong year on 30 and 31 of december

    Posted 01-08-2019 09:20 AM
      |   view attached

    We have a service on the apigw where we must use a date in the following format: YYYY-MM-DD+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?

     

    Thanks in advance!

    Attachment(s)

    zip
    dateTest.xml.zip   620B 1 version


  • 2.  Re: API Gateway Time-Variable has wrong year on 30 and 31 of december

    Posted 01-08-2019 02:02 PM

    Good afternoon,

     

    A few questions, what gateway version are you trying this on and what is the timezone setting for the OS?

     

    Sincerely,

     

    Stephen Hughes

    Broadcom Support



  • 3.  Re: API Gateway Time-Variable has wrong year on 30 and 31 of december

    Posted 01-09-2019 05:03 AM

    Hi,

     

    The problem occured first on a 9.1 API Gateway and I could reproduce it also on a 9.4 API Gateway.

    The timezone is UTC+1.

     

    Regards,

    Andi



  • 4.  Re: API Gateway Time-Variable has wrong year on 30 and 31 of december
    Best Answer

    Posted 01-17-2019 07:51 AM

    Thanks to SayeedI who found out the root of the Problem. Here is his answer:

     

    Hello Andreas,

    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 whereas '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'.

    Thanks.

    Regards

    -SAyeed

    CA Support