Android : Fit the calendar format

on Wednesday, August 13, 2014


I want mask yyyy/mm/dd


so.. I have used this code.



SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
Calendar today = new GregorianCalendar();
String x = today.get(Calendar.YEAR)+"/"+today.get(Calendar.MONTH)+"/"+today.get(Calendar.DATE);
String a = format.format(x);
system.out.println(a);


I using this code But this was exception output.



08-14 15:24:36.327: E/AndroidRuntime(10133): java.lang.IllegalArgumentException


The exception here is the output.



String a = format.format(x);


the x output 2014/8/14. it mask yyyy/m/d


What do I need to fix?


0 comments:

Post a Comment