fork(14) download
  1. import java.util.Calendar;
  2. import java.util.Date;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. Calendar calendar = Calendar.getInstance();
  7. calendar.setTime(new Date());
  8. int round = calendar.get(Calendar.MINUTE) % 15;
  9. calendar.add(Calendar.MINUTE, round < 8 ? -round : (15-round));
  10. calendar.set( Calendar.SECOND, 0 );
  11. System.out.println(calendar.getTime());
  12. }
  13. }
  14.  
Success #stdin #stdout 0.06s 711680KB
stdin
Standard input is empty
stdout
Tue Jan 03 08:15:00 GMT 2017