java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
String date = dateFormat.format(new Date());
目前我可以使用这段代码以dd/mm/yyyy格式获取时间。
我希望得到的是没有格式的日期和时间。
对于15/04/2011 12:00:00,我想要:
15042011120000
?
java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
String date = dateFormat.format(new Date());
目前我可以使用这段代码以dd/mm/yyyy格式获取时间。
我希望得到的是没有格式的日期和时间。
对于15/04/2011 12:00:00,我想要:
15042011120000
?
SimpleDateFormat
类:SimpleDateFormat s = new SimpleDateFormat("ddMMyyyyhhmmss");
String format = s.format(new Date());
DateFormat
对象(静态存储),并以相同方式使用它:dateFormat = new SimpleDateFormat("ddMMyyyyHHmmss");
String date = dateFormat.format(new Date());
Calendar c1 = Calendar.getInstance();
String myfrmt = c1.get(Calendar.YEAR) + c1.get(Calendar.MONTH) + c1.get(Calendar.DAY_OF_MONTH) + c1.get(Calendar.HOUR_OF_DAY) + c1.get(Calendar.MINUTE);