开发者

Question about android date formatting

There are two source codes of android, but I don't understand what they mean. And the phone can't change the dateformat, the dateformat is always wday_month_day_no_year.

mTimeFormat = DateFormat.getTimeFormat(getContext());
        mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
        refreshTimeAndDateDisplay();
        updateStatusLines();



public void onTimeChanged() {
        refreshTimeAndDateDisplay();
    }

    private void refreshTimeAndDateDisplay() {
        mDate.setText(DateFormat.format(mDateFormatString, new Date()));
    }

what's the meaning of mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);?

Well,I change the DateFormat,But in the lockscreen,that is not showing the date by the dateformat I set.So I don't know what's wrong with it.In the lockSreen it always show the date by "full_wday_month_d开发者_运维百科ay_no_year" format.

please help me to solve the problem.


the format() method takes a string as a first parameter. In this particular case, the string is defined in the resources, specifically in the file located at res/values/strings.xml, as

<string name="full_wday_month_day_no_year">E M d</string>

or similar

The reference for DateFormat: http://developer.android.com/reference/android/text/format/DateFormat.html

and for string resources: http://developer.android.com/guide/topics/resources/string-resource.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜