一、遍历map,并对里面的值类型判断
1、通过EntrySet取出map数据[Iterator遍历]
2、采用 instanceof 判断数据类型
3、格式化时间可以用 org.apache.commons.lang3.time.DateFormatUtils 这个方法
public class Test {
public static void main(String[] args) {
Map<String, Object> param = new HashMap<String, Object>();
param.put("name", "liming");
param.put("age", Integer.parseInt("12"));
param.put("birthate", new Date());
for (Map.Entry<String, Object> entry : param.entrySet()) {
Object value = entry.getValue();
if(value instanceof Integer){
System.out.println("int类型");
}else if(value instanceof String){
System.out.println("String类型");
}else if(value instanceof Date){
Date date=(Date)value;
System.out.println(DateFormatUtils.format(date,"yyyy-MM-dd"));
System.out.println("时间类型");
}
}
}
}