For the below code I intended to get the system date and display it as per the formatting of the current locale, it's just that for the R.string.date
. In emulator it always shows up as a long number (something like 821302314) instead of "Date: " which I has already externalized in the string.xml
. Can anyone help to have a look why this is so?
final TextView mTimeText = (TextView)findViewById(R.id.mTimeText);
//get system date
Date date = new Date();
java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
mTimeText.setText(R.string.date + " " + dateFormat.format(date));
layout.xml
<TextView
android:id="@+id/mTimeText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/date"
/>
strings.xml
<string name="date">Date:</string>