Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 890
user590849 Avatar asked Apr 22 '11 11:04

user590849


1 Answers

String cdate = (String) DateFormat.format("yyyy-MM-dd kk:mm:ss", c.getTime());
like image 106
kp666 Avatar answered Sep 29 '22 12:09

kp666