android同步系统时间日期
protected void whetherLocateCN(long date) {
boolean b24 = DateFormat.is24HourFormat(this);
String format =Settings.System.getString(getContentResolve(),Settings.System.DATE_FORMAT);//获取设置中的时间改变
if(format==null||format.equals("")){
if(Locale.getDefault().toString().startsWith("zh")) {
format = "yyyy-MM-dd ";
} else if (Locale.getDefault().toString().startsWith("en")) {
format = "dd/MM/yyyy ";
} else {format = "yyyy-MM-dd ";
}
}else{
format +=" ";
}if(b24) {
format += "HH:mm";
} else {format += "hh:mm a";
}SimpleDateFormat sdf = new SimpleDateFormat(format,Locale.getDefault());
createDate.setText(sdf.format(date));
}