In your project you have some date and as project requirement you want to convert it into milliseconds or while code you need to convert date into other format, I am same date in file saving, long date is used in file name but it use depend on the developer.
1) First convert string to java.Date using simpledateformatter
2) Use getTime method to obtain count of millisecs from date
public class test {
public static void main(String[] args) {
String currentDate = "01-March-2016";
SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy");
Date parseDate = f.parse(currentDate);
long milliseconds = parseDate.getTime();
}
}
1) First convert string to java.Date using simpledateformatter
2) Use getTime method to obtain count of millisecs from date
public class test {
public static void main(String[] args) {
String currentDate = "01-March-2016";
SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy");
Date parseDate = f.parse(currentDate);
long milliseconds = parseDate.getTime();
}
}
No comments
Post a Comment