Parsing a JSON date is rather easy, and doesn’t even require jQuery. Since the JSON date format is always the same, you can use substr to retrieve the timestamp and parse it to a date. var date = new Date(parseInt(jsonDate.substr(6))); There’s nothing more to it; it’s that easy!
To add years, days, hours or minutes to a Date object in Java, you need to use the java.util.Calendar class. //Adds one day to the current date Calendar cal = Calendar.getInstance(); // The current date cal.add(Calendar.DAY_OF_MONTH, 1); Date date = cal.getTime(); // 1 day in the future If you want to substract time, simply use […]
Creating a new date in Java is quite simple. Use the Calendar class to quickly create your Date object //Generate a date for Jan. 9, 2013, 10:11:12 AM Calendar cal = Calendar.getInstance(); cal.set(2013, Calendar.JANUARY, 9); //Year, month and day of month Date date = cal.getTime(); If you also need to set the time, you can […]