I have a JSON input. I would like to convert all timestamp (createdDate ,modifiedDate) to time in ruby. How do I do that? I tried below methods but dint work
characterList.each { |char| DateTime.strptime(char.try(:getEditInfo).try(:getCreatedDate),%s) } {"characterList": [ {"editInfo": {"createdBy": "testname", "createdDate": 1503137795000, "modifiedBy": "testname", "modifiedDate": 1503137795000}, "charInfo": {"charid": "3434", "charDesc": "3434", "status": "ON"} }, {"editInfo": {"createdBy": "testname", "createdDate": 1503137795000, "modifiedBy": "testname", "modifiedDate": 1503137795000}, "charInfo": {"charid": "3434 6", "charDesc": "43dfdf", "status": "ON"} }, {"editInfo": {"createdBy": "testname", "createdDate": 1503137795000, "modifiedBy": "testname", "modifiedDate": 1503137795000}, "charInfo": {"charid": "4hr_SLA", "charDesc": "sd", "status": "ON"} }, {"editInfo": {"createdBy": "testname", "createdDate": 1503137795000, "modifiedBy": "testname", "modifiedDate": 1503137795000}, "charInfo": {"charid": "aaaaaaaaaa", "charDesc": "asdfaadsf asdfasdf asdf", "status": "ON"} }, {"editInfo": {"createdBy": "testname", "createdDate": 1503137795000, "modifiedBy": "testname", "modifiedDate": 1503137795000}, "charInfo": {"charid": "abababab", "charDesc": "abababababab", "status": "ON"} } ]}
I am ok converting in 2 like separately for createdDate and modifiedDate. But Im looking for one line solution