티스토리 뷰

SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");

Calendar cal = new GregorianCalendar(Locale.KOREA);

String dateOri="20190806010203";
Date setDate=sdf.parse(dateOri);

String strHH = new SimpleDateFormat("HH").format(setDate);

int hh=Integer.parseInt(strHH);

if(hh>=0 && hh<=7){
  cal.setTime(setDate);
  cal.add(Calendar.DATE, -1);
  String yest=sdf.format(cal.getTime());
}

'자바(Java)' 카테고리의 다른 글

자바 mybatis standalone  (0) 2019.08.21
자바 spring mybatis standalone  (0) 2019.08.19
java – 날짜 문자열에서 시간 추출  (0) 2019.08.06
자바 파일 읽기 및 이동  (0) 2019.08.05
자바 개행문자 추가 파일 쓰기  (0) 2019.08.05
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
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
글 보관함