Advertisement
cd62131

Print Time

Dec 18th, 2013
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.65 KB | None | 0 0
  1. import java.util.Calendar;
  2. import java.util.Random;
  3.  
  4. public class HourAndMinute {
  5.   public static void main(String[] args) {
  6.     Calendar c = Calendar.getInstance();
  7.     c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE), 0,
  8.       0, 0);
  9.     c.set(Calendar.MILLISECOND, 0);
  10.     Calendar d = (Calendar )c.clone();
  11.     d.add(Calendar.DATE, 1);
  12.     StringBuilder sb = new StringBuilder();
  13.     while (c.compareTo(d) < 0) {
  14.       Random r = new Random();
  15.       sb.append(String.format("%tk:%tM %08d\n", c, c,
  16.         r.nextInt((int )Math.pow(10, 8) - 1)));
  17.       c.add(Calendar.MINUTE, 5);
  18.     }
  19.     System.out.println(sb);
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement