2 Replies Latest reply on Mar 21, 2012 7:57 PM by phneville

    Date format

    phneville

      I have a property of type Date formatted like so 2007-01-15T00:00:00.000+08:00. 

      Would there be problems if I change that value to 2007-01-15T00:00:00.000+0800 (without the colon on the timezone offset part)?

        • 1. Re: Date format
          hypnotec Adobe Employee

          you cannot change the "format" of the date stored in a date property. you can of course format the output after reading the date from the property:

           

          via sling API / resource resolver:

           

          ValueMap properties = resourceResolver.getResource("/my/node").adaptTo(ValueMap.class);

          Calendar cal = properties.get("myDate", Calendar.class);

           

          or via JCR api:

           

          Calendar cal = session.getNode("/my/node").getProperty("myDate").getDate();

           

          and then format:

           

          String formattedDate = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());

          1 person found this helpful
          • 2. Re: Date format
            phneville Level 1

            Thank you.