android - Show date in current locale -


i have input date-time string:

2012-06-04 15:41:28

i display various countries. example, in europe have dd.mm.yyyy whereas uses mm/dd/yyyy.

my current code this:

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()); 

but doesn't work want (i "uniform" result "jun 4, 2012 3:41:28 pm", on phone). doing wrong?

try this:

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 medium, , 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 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -