반응형

→ 오늘 날짜 yyyy/MM/dd 형식으로 나타내기

Date date = new Date();

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

String toDay = sdf.format(date);

toDay.replaceAll("-", "/");


결과 : 2016/09/28


→ 오늘로부터 2달 전 날짜 구하기

Calendar cal = new GregorianCalendar(Locale.KOREA);

cal.setTime(date);

cal.add(Calendar.MONTH, -2);

String twoMonthAgo = sdf.format(cal.getTime());

twoMonthAgo.replaceAll("-", "/");


결과 : 2016/07/28


날짜 관련하여서 필요한데로 커스터마이징이 필요한 경우 하기 사이트 참고하여서 개발하세요~

http://betatester.tistory.com/16

반응형

+ Recent posts