Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.GregorianCalendar; public class Main { static Calendar toNearestWholeMinute(Calendar d) { Calendar c = new GregorianCalendar(); c.setTime(d.getTime()); if (c.get(Calendar.SECOND) >= 30) c.add(Calendar.MINUTE, 1); c.set(Calendar.SECOND, 0); return c; } }