Java常用工具類--持續更新中

1、數據類型轉換

//實體轉vo
BeanUtils.copyProperties(testDemoFrom,testDemoDTO);

//JSONObject轉map
List<Map<String,String>> mapList = JSONObject.parseObject(jsonObject.toJSONString(), new TypeReference<List<Map<String, String>>>(){});

2、時間獲取以及格式化
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss”);//時間格式
format.format(new Date()); //獲取當前時間
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) +7);//獲取7天后的時間
format.format(calendar.getTime());//格式化時間

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章