Add 30 minutes to the current time in java

Use the following:

//get current Time
long currentTime = System.currentTimeMillis();
//now add half an hour, 1 800 000 miliseconds = 30 minutes
long halfAnHourLater = currentTime + 1800000;

System.currentTimeMillis()+(30*60*1000);

Calendar now = Calendar.getInstance();
now.add(Calendar.MINUTE, 30);

And to output the time you could use

// 24 hours format
SimpleDateFormat df = new SimpleDateFormat("HH:mm");
// AM/PM format
SimpleDateFormat df = new SimpleDateFormat("hh:mm aa");

System.out.println(df.format(now.getTime()));

Tags:

Java

Android