Answers for "time to long java"

2

java cast duration to long

Duration d = Duration.ofHours(1); 	// 1 hour with java.time
long millis = d.toMillis();			// 1 hour in milliseconds
Posted by: Guest on March-20-2020
2

get long from date java

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();
}
Posted by: Guest on March-28-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language