In this program, we will get the milliseconds from a date in the specified format and print the result.
Program/Source Code:
The source code to get milliseconds from a specified date is given below. The given program is compiled and executed successfully.
// Java program to get milliseconds from
// specified date
import java.util.*;
import java.text.SimpleDateFormat;
public class Main {
public static void main(String[] args) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-M-yyyy");
String dateString = "15-03-1993";
try {
Date dt = dateFormat.parse(dateString);
System.out.println("Date in milliseconds: " + dt.getTime());
} catch (Exception e) {
e.printStackTrace();
}
}
}
In this program, we will get the milliseconds from a date in the specified format and print the result.
Program/Source Code:
The source code to get milliseconds from a specified date is given below. The given program is compiled and executed successfully.
Output: