开发者

some DateFormat AM/PM formatting options don't appear to be working on AVD for API Level 8

android.text.format.DateFormat specifies that using the format string 'a' should yield 'a' or 'p' and 'aa' should yield 'am' or 'pm'. However, on my AVD, using 'a', 'A', or 'AA' yields 'am' or 'pm' which is not congruent with the on-line documentation.

final long currentTimeMillis = System.currentTimeMillis();

Log.i("DateFormat", "a: " + (String) DateFormat.format("a", currentTimeMillis));
Log.i("DateFormat", "aa: " + (String) DateFormat.format("aa", currentTimeMillis));
Log.i("DateFormat", "A: " + (String) DateFormat.format("A", currentTimeMillis));
Log.i("DateFormat", "AA: " + (String) DateFormat.format("AA", currentTimeMillis));

Since DateFormat 开发者_JS百科has been available since API Level 3, am I running into a regression or is there something wrong with my development environment? (I'm new to android so I don't have much experience with this framework yet). AVD is configured for API Level 8 and I'm using Eclipse.


Try using the SimpleDateFormat as explained on Android Developer

SimpleDateFormat sdf = new SimpleDateFormat("a hh-mm-ss");
date = new Date();
sDate = sdf.format(date);


Finally got around to looking at the source code and as far as I can tell, these formatting options were never implemented correctly. Only 2 possible localized strings are retrieved and they are not manipulated any further, which is what I'm observing.

I've filed a bug: http://code.google.com/p/android/issues/detail?id=16997

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜