목록calendar (2)
정미나닷컴
[Java] 자바 String, Date, Calendar 형변환
String sDate = "20161026"; SimpleDateFormat sdFormat = new SimpleDateFormat("yyyyMMdd"); // sDate와 형식이 맞아야 함 Date date = transFormat.parsesDate; // String -> Date 전환 Calendar tmpDate = Calendar.getInstance(); tmpDate.setTime(date); // Date -> Calendar 전환 tmpDate.add(Calendar.DATE, -3); // 3일전 계산 SimpleDateFormat transFormat2 = new SimpleDateFormat("yyyy년 MM월 dd일"); // 원하는 출력 형식 System.out.printl..
programming
2016. 10. 26. 15:41
[JSP] JSP 시간 비교
Calendar cal = Calendar.getInstance(); long currentTime = cal.getTimeInMillis(); cal.set(2010, 03, 19, 00, 0); // 기준일 2010년 4월 19일 00시 long tmpTime = cal.getTimeInMillis(); if ( currentTime - tmpTime < 0 ) { out.println("이전"); }else{ out.println("이후"); }
programming
2010. 4. 19. 09:22