如何转换Fri Dec 29 05:30:00 GMT 05:30 20进29-12-2017 02:28:03这个格式在android.i已经使用下面的代码转换日期但我可以&# 39; t work.so请帮帮我。
String date = Fri Dec 29 05:30:00 GMT 05:30 20
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy h:mm:ss");
Date date1 = sdf.parse(date);
答案 0 :(得分:0)
以下两种根据您的要求转换日期的方法
//将TimeStamp date(long)转换为String ... in Date
的方法public static String makeLongTODate(long dateTime) {
Date d = new Date(dateTime);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH);
String date = simpleDateFormat.format(d);
return date;
}
//method for converting TimeStamp date(long) to String... in date & Time
public static String makeLongTODateTime(long dateTime) {
Date d = new Date(dateTime);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.ENGLISH);
String date = simpleDateFormat.format(d);
return date;
}