Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
320 views
in Technique[技术] by (71.8m points)

java - 24 hour clock not working in dateformat android

i have made an application in which i need to perform date conversion in 24 hour format. Here is my code.

GregorianCalendar c = new GregorianCalendar(Locale.GERMANY);
            c.set(2011, 04, 29,0,0,0);
            String cdate = (String) DateFormat.format("yyyy-MM-dd HH:mm:ss", c.getTime());
            Log.i(tag,cdate);

now when i check my LOG here is the output:

04-22 12:44:15.956: INFO/GridCellAdapter(30248): 2011-04-29 HH:00:00

why is the hour field not getting set. i have explicitly passed 0 when i was making the calendar object, still it is display HH in the LOG. i have tried while passing hh, that is being set, but HH is not being set.

what could be the problem?

thank you in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
String cdate = (String) DateFormat.format("yyyy-MM-dd kk:mm:ss", c.getTime());

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...