fork(2) download
  1.  
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5. import java.time.*;
  6. import java.time.temporal.ChronoField;
  7. import java.time.temporal.ChronoUnit;
  8.  
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. LocalTime now = LocalTime.now();
  14. System.out.println(now);
  15.  
  16. LocalTime next = now.with((temp) -> {
  17. int currentMinute = temp.get(ChronoField.MINUTE_OF_DAY);
  18. int interval = (currentMinute / 15) * 15;
  19. interval = interval - currentMinute;
  20. temp = temp.plus(interval, ChronoUnit.MINUTES);
  21. return temp.plus(15, ChronoUnit.MINUTES);
  22. });
  23. System.out.println(next);
  24. }
  25. }
Success #stdin #stdout 0.09s 711680KB
stdin
Standard input is empty
stdout
10:09:08.141
10:15:08.141