//https://www.mkyong.com/java/java-how-to-add-days-to-current-date/ import java.util.Calendar; import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; DateFormat df = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); Date d1 = df.parse("2018-08-19T22:09:25.100Z"); Calendar c = Calendar.getInstance(); c.setTime(d1); c.add(Calendar.HOUR, 11); // convert calendar to date Date currentDatePlusOne = c.getTime(); System.out.println(df.format(currentDatePlusOne)); /*Calendar calendar = Calendar.getInstance(); System.out.println("Original = " + calendar.getTime()); // Substract 2 hour from the current time calendar.add(Calendar.HOUR, -2); // Add 30 minutes to the calendar time calendar.add(Calendar.MINUTE, 30); // Add 300 seconds to the calendar time calendar.add(Calendar.SECOND, 300); System.out.println("Updated = " + calendar.getTime()); */
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more