Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- netsh
- Windows
- VirtualBox
- maVen
- plugin
- Windows 10
- context
- resource
- tomcat
- IntelliJ
- JavaScript
- GIT
- vscode
- port
- profile
- find
- Source
- 네트워크
- Eclipse
- Mac
- grep
- xargs
- web.xml
- 줄바꿈 문자
- ssh
- 단축키
- import
- Quartz
- lsof
- bash
Archives
- Today
- Total
develog
[java] Calendar, 1년전, 한달전, 하루전 본문
private String getCustomDate(String yyyymmdd) {
int year = Integer.parseInt(yyyymmdd.substring(0, 4));
int month = Integer.parseInt(yyyymmdd.substring(4, 6));
int date = Integer.parseInt(yyyymmdd.substring(6, 8));
Calendar cal = Calendar.getInstance();
cal.set(year, month - 1, date);
cal.add(Calendar.YEAR, -1); // 1년 전
cal.add(Calendar.MONTH, -1); // 한달 전
cal.add(Calendar.DATE, -1); // 하루 전
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd");
return dateFormatter.format(cal.getTime());
}
'Dev > Java' 카테고리의 다른 글
줄바꿈 문자 (0) | 2012.06.13 |
---|---|
java file copy test (0) | 2012.05.24 |
SimpleDateFormat (0) | 2012.05.10 |
Thread (0) | 2012.05.10 |
console 에서 java 실행 (0) | 2012.05.09 |
Comments