android获取年月日时分秒

时间:2021-12-12 12:57:49
Calendar calendar=Calendar.getInstance();  //获取当前时间,作为图标的名字
String year=calendar.get(Calendar.YEAR)+"";
String month=calendar.get(Calendar.MONTH)+1+"";
String day=calendar.get(Calendar.DAY_OF_MONTH)+"";
String hour=calendar.get(Calendar.HOUR_OF_DAY)+"";
String minute=calendar.get(Calendar.MINUTE)+"";
String second=calendar.get(Calendar.SECOND)+"";
String time=year+month+day+hour+minute+second;