因为经常有需求要获取当前年月日并且进行一些拼接,所以自己写了个公共方法来实现:
/*** * * @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; }
这样就可以了!
标签:map,Map,放到,获取,result,年月日,now,Calendar From: https://www.cnblogs.com/ssbxfsrm/p/17037652.html