今天的時間加一天java
阿新 • • 發佈:2019-01-28
JSONObject queryJson = null;
SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd");
Date parse = null;
try {
parse = formatter.parse(queryBody);
} catch (ParseException e) {
e.printStackTrace();
}
if (StringUtils.isBlank(queryBody)) {
queryJson = new JSONObject();
} else {
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
//+1今天的時間加一天
calendar.add(Calendar.DAY_OF_MONTH, +1);
Date parse1 = calendar.getTime();
String endTime = formatter.format(parse1);
//string型別的json
String str = "{\"startTime\":\""+queryBody+"\",\"endTime\":\""+endTime+"\"}";
if(str!=null){
queryJson = JSON.parseObject(str);
}else{
queryJson = JSON.parseObject(queryBody);
}
}