I am getting a Date datatype from the database like this Mon Sep 14 11:30:00 GMT+03:00 2020.I want to change this value to a string so I used this function.
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm";
public static String dateToString(Date date){
DateFormat dateFormat = new SimpleDateFormat(General.DATE_FORMAT);
dateFormat.setTimeZone(TimeZone.getDefault());
if(date == null)
return "";
return dateFormat.format(date);
}
This function is given me this output 2020-09-14 11:30 but it should be 2020-09-14 02:30 according to my android device time zone. Any suggestions ?