您好我从服务器获取这种格式的时间:Fri Nov 03 09:12:44 GMT+05:30 2017
我希望以yyyy-MMM-dd hh:mm a
我在这里做了什么,
if (!appPreference.getServerDateTime().isEmpty()) {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
Date newDate = format.parse(appPreference.getServerDateTime());//2017-11-03 09:12:44
format = new SimpleDateFormat("yyyy-MMM-dd hh:mm a");
String date = format.format(newDate);
dateFromUTC(newDate);
mInitView.tv_lastEditeTime.setText(String.valueOf(dateFromUTC(newDate)));
Log.d("time", "onCreateView: " + date);
} catch (Exception e) {
e.printStackTrace();
}
}
return view;
}
public static Date dateFromUTC(Date date) {
return new Date(date.getTime() + Calendar.getInstance().getTimeZone().getOffset(date.getTime()));
}
但我的格林尼治标准时间相同。请指导我