mardi 6 juin 2017

Comparing SimpleDateFormat output with number

I am making a program that executes something every time the time reaches an hour.

Here is the code:

import java.text.*;
import java.util.Date;
class NMAP {
 public static void main(String[] args) {
  DateFormat dateFormat = new SimpleDateFormat("HH");
  Date date = new Date();
  if (dateFormat.format(date).equals(17)) {
   System.out.println(dateFormat.format(date));
  }
 }
}

It should be outputting 17 (since it is 17:00), but it doesn't output anything.

Why not?

Aucun commentaire:

Enregistrer un commentaire