Java hat die Dauer bis zu lang gegossen
Duration d = Duration.ofHours(1); // 1 hour with java.time
long millis = d.toMillis(); // 1 hour in milliseconds
LucasP243
Duration d = Duration.ofHours(1); // 1 hour with java.time
long millis = d.toMillis(); // 1 hour in milliseconds
String string_date = "12-December-2012";
SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy");
try {
Date d = f.parse(string_date);
long milliseconds = d.getTime();
} catch (ParseException e) {
e.printStackTrace();
}
//The Date constructor (click the link!) accepts the time as long in milliseconds, not seconds.
long currentDateTime = System.currentTimeMillis();
//creating Date from millisecond
Date currentDate = new Date(currentDateTime);