The program takes a specific date in the format "dd-M-yyyy" as a string input and converts it into a Date object using SimpleDateFormat class. Then it prints the corresponding milliseconds of the date using getTime() method of Date class. Here's how the program works:
import java.util.*; import java.text.SimpleDateFormat; public class Millisecond_SpecifiedDate { public static void main(String[] args) { SimpleDateFormat dt_formate = new SimpleDateFormat("dd-M-yyyy"); String str_date = "18-06-2014"; try { Date dt = dt_formate.parse(str_date); System.out.println("Date in Milliseconds : " + dt.getTime()); } catch (Exception e) { e.printStackTrace(); } } }
Date in Milliseconds : 1403029800000
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions