아디봉의.net

[JAVA] 자바 날짜 오늘부터 30일후 셋팅 본문

JAVA

[JAVA] 자바 날짜 오늘부터 30일후 셋팅

아디봉 2013. 12. 24. 10:32

//날짜가 없으면 오늘부터 ~30일후 셋팅

System.out.println("searchBtn>>>>>>>>>>");

//포맷설정

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

Calendar cl = new GregorianCalendar(Locale.KOREA);

Date date = new Date();

cl.setTime(date);

String betweenDt = sdf.format(date);

//Date endDt = new Date();

cl.add(cl.DATE, 30);

String endDt = sdf.format(cl.getTime());

/*String yearDt = String.valueOf(cl.get(cl.YEAR));

String monthDt = String.valueOf(cl.get(cl.MONTH)+1);

String dateDt= String.valueOf(cl.get(cl.DATE));

String sumDt = yearDt + monthDt + dateDt;

String endDt = sdf.format(sumDt);*/

//System.out.println(">>>>>>>>"+betweenDt+">>>>>>>>"+endDt);