How to convert milliseconds to date in java?

2.23K viewsJava

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

Changed status to publish
Add a Comment

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();
DateFormat formatter = new SimpleDateFormat(dateFormat);
Date convertedDate=convertStrToDate(formatter.format(calendar.getTimeInMillis()),dateFormat);
return convertedDate;


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