spring memo

java date control

고랑이. 2018. 7. 24. 11:19

[string to date]

String thisDay = param.get("date").toString();

SimpleDateFormat transFormat = new SimpleDateFormat("yyyy-MM-dd");

Calendar calendar = Calendar.getInstance();

Date date = transFormat.parse(thisDay);


[date to string]

String nextDay = transFormat.format(date);

 

https://www.javatpoint.com/java-string-to-date

 


[string ad nextday]

String thisDay = param.get("date").toString();

SimpleDateFormat transFormat = new SimpleDateFormat("yyyy-MM-dd");



Calendar calendar = Calendar.getInstance();

Date date = transFormat.parse(thisDay);

calendar.setTime(date);

calendar.add(Calendar.DATE,1);

String nextDay = transFormat.format(calendar.getTime());