Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-7748

Value of Month from jcr:lastModified is INCORRECT when org.apache.sling.api.resource.Resource.getValueMap() is used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • API 2.16.2
    • None
    • API
    • None

    Description

      When using org.apache.sling.api.resource.Resource , the method getValueMap ( https://sling.apache.org/apidocs/sling9/org/apache/sling/api/resource/Resource.html#getValueMap-- ), returns a ValueMap of all the properties. 

      We observed that the "month" in "jcr:lastModified" is off by 1 month. While Year, Day, Hour, Min, Seconds are all correct. Please see the attachments. And this is the same for all Nodes.

      The last date modified was "2018-05-29T10:31:49.123-05:00" while the value from the above method returned as below:

      jcr:lastModified\"{\"year\":2018,*\"month\":4,\{color}*"dayOfMonth\":29,\"hourOfDay\":10,\"minute\":31,\"second\":49}

      We did not test this on all nodes though.

       

      Sample code:

      Resource jcrdataResource = resource.getChild("jcr:content");
      ValueMap jcrProperties = ResourceUtil.getValueMap(jcrdataResource);
      ...
      JsonObject assetMetadataJson.addProperty(hit.getPath(), new Gson().toJson(allProperties));
      ...
      JsonElement assetMetadataJsonElement = new Gson().fromJson(assetMetadataJson.toString(), JsonElement.class);
      ...
      JsonObject mainjsonObject.add("assets", assetMetadataJsonElement);
      
      return mainjsonObject;
      

       

      Attachments

        1. 12928514_how-to-create2.png
          67 kB
          Jason E Bailey
        2. how-to-create.png
          85 kB
          Suren Konathala
        3. how-to-create.png
          85 kB
          Suren Konathala
        4. indy.png
          103 kB
          Suren Konathala
        5. indy2.png
          104 kB
          Suren Konathala
        6. sand.png
          173 kB
          Suren Konathala
        7. sand.png
          173 kB
          Suren Konathala
        8. Screen Shot 2018-06-19 at 4.09.38 PM.png
          167 kB
          Suren Konathala
        9. Screen Shot 2018-06-19 at 4.09.56 PM.png
          327 kB
          Suren Konathala
        10. service-result.png
          582 kB
          Suren Konathala
        11. service-result.png
          582 kB
          Suren Konathala

        Activity

          People

            Unassigned Unassigned
            ksurendra Suren Konathala
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: