以当前区域设置显示日期

Pri*_*alj 6 android locale localization date

我有一个输入日期时间字符串:

2012-06-04 15:41:28

我想为各个国家正确展示它.例如,在欧洲,我们有dd.MM.yyyy,而美国则使用MM/dd/yyyy.

我目前的代码是这样的:

TextView timedate = (TextView) v.findViewById(R.id.report_date);
SimpleDateFormat curFormater = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss"); 
curFormater.setTimeZone(TimeZone.getDefault());
Date dateObj = curFormater.parse(my_input_string); 
timedate.setText(dateObj.toLocaleString());
Run Code Online (Sandbox Code Playgroud)

但它并不能完全符合我的要求(我总是得到"统一"结果,如"Jun 4,2012 3:41:28 PM",即使在我的手机上).我究竟做错了什么?

len*_*ooh 4

尝试这个:

TextView timedate = (TextView) v.findViewById(R.id.report_date);
SimpleDateFormat curFormater = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss"); 
curFormater.setTimeZone(TimeZone.getDefault());
Date dateObj = curFormater.parse(my_input_string);

int datestyle = DateFormat.SHORT; // try also MEDIUM, and FULL
int timestyle = DateFormat.MEDIUM;
DateFormat df = DateFormat.getDateTimeInstance(datestyle, timestyle, Locale.getDefault());

timedate.setText(df.format(dateObj)); // ex. Slovene: 23. okt. 2014 20:34:45
Run Code Online (Sandbox Code Playgroud)