How to convert milliseconds to date in java?

3.79K viewsJava
0

Convert Milliseconds to a Date Format in Java, like as below as  M yyyy HH:mm:ss: SSS Z format.

Manohar Changed status to publish June 16, 2019
Add a Comment
0

Use below snippet code convert milliseconds to a date format :

public Date convertMilliSecondsToDate(String milliSeconds,String dateFormat) {
long dateTimeInMilliSeconds = Long.parseLong(milliSeconds);
Calendar calendar=Calendar.getInstance();
calendar.setTimeInMillis(dateTimeInMilliSeconds);
DateFormat formatter = new SimpleDateFormat(dateFormat);
Date convertedDate=convertStrToDate(formatter.format(calendar.getTimeInMillis()),dateFormat);
return convertedDate;

}

Manohar Changed status to publish June 16, 2019
Add a Comment
You are viewing 1 out of 1 answers, click here to view all answers.
Write your answer.