Posts

Showing posts from August, 2020

Sorting and comparting List Of Json Object

 import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; import org.json.JSONException; import org.json.JSONObject; public class TestClass { static DateFormat df = new SimpleDateFormat("yy-MM-dd hh:mm:ss aa");     Date dateobj = new Date();      @SuppressWarnings("deprecation") public static void main(String[] args) { JSONObject dbObject1 = new JSONObject(); dbObject1.put("name", "abc.pdf"); dbObject1.put("UniqueId", "123-456-789-001"); dbObject1.put("createdDate", df.format(new Date(2019,8,28,10,22,11))); dbObject1.put("modifiedDate", df.format(new Date(2020,8,28,10,22,12))); dbObject1.put("docKey", "9876-345"); JSONObject dbObject2 = new JSONObject(); dbObject2.put("name", "abc.pdf"); db