获取当前日期并把年月日放到map中
因为经常有需求要获取当前年月日并且进行一些拼接,所以自己写了个公共方法来实现:
/*** * * @return获取当天年月日 */ public static Map<String,Object> getCurrentDate(){ Calendar now = Calendar.getInstance(); Map<String,Object> result=new HashMap<>(); result.put("年",now.get(Calendar.YEAR)); result.put("月",(now.get(Calendar.MONTH) + 1)<10?"0"+(now.get(Calendar.MONTH) + 1):(now.get(Calendar.MONTH) + 1)); result.put("日",now.get(Calendar.DAY_OF_MONTH)<10?"0"+now.get(Calendar.DAY_OF_MONTH):now.get(Calendar.DAY_OF_MONTH)); return result; }
这样就可以了!

浙公网安备 33010602011771号