SHARE
TWEET

Untitled

a guest Jan 12th, 2017 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.text.ParseException;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Calendar;
  4. import java.util.Date;
  5.  
  6. public class wielange {
  7.  
  8.     public static void main(String[] args) throws ParseException {
  9.         // TODO Auto-generated method stub
  10.        
  11.    
  12.        
  13.         while(true){
  14.             String time2 = "11:30:00";
  15.             String time1 = new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime());
  16.             SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
  17.             Date date1 = format.parse(time1);
  18.             Date date2 = format.parse(time2);
  19.             long difference = date2.getTime() - date1.getTime();
  20.             long minutes = difference/1000;
  21.             System.out.println(minutes + "Sekunden noch!");
  22.             try {
  23.                 Thread.sleep(1000);                 //1000 milliseconds is one second.
  24.             } catch(InterruptedException ex) {
  25.                 Thread.currentThread().interrupt();
  26.             }
  27.         }
  28.  
  29.     }
  30.  
  31. }
RAW Paste Data
Want to get better at Java?
Learn to code Java in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top