I want to convert this timestamp format 2021-04-21T17:00:50
to "dd/MM/YYYY"
I'm getting number format exception:
public static final String DATE_FORMAT = "dd-MMM-yyyy";
private String courseStartDate = null;
long longDate = 2021-04-21T17:00:50;
courseStartDate = getDateTimeFromTimeStamp(longDate, DATE_FORMAT);
public String getDateTimeFromTimeStamp(Long time, String mDateFormat) {
SimpleDateFormat dateFormat = new SimpleDateFormat(mDateFormat);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date dateTime = new Date(time);
return dateFormat.format(dateTime);
}
LocalDateTime
.parse( "2021-04-21T17:00:50" )
.format(
DateTimeFormatter.ofPattern( "dd/MM/uuuu" )
)
This has been covered many many times. So search to learn more.