IT/Java (1) 썸네일형 리스트형 Java 두 날짜사이의 간격 (Date 쓰지말것) Java로 개발할때 두 시간(DateTime)사이의 간격을 시간, 초 등으로 계산이 필요한 경우가 있다. 1. Date.getTime()을 이용 : 이렇게 하면 안된다. private long getSecTime(String endDate, String startDate) throws Exception{ try{ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date d1 = sdf.parse( endDate ); Date d2 = sdf2.parse( startDate ); long longSec = (d1.. 이전 1 다음