본문 바로가기
컴퓨터이야기/JAVA&JSP

날짜 변환하여 계산 하기

by 변화지시자 2013. 4. 3.
반응형
<%@page import="java.awt.SystemTray"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>

    BookRent_Bean brBean= (BookRent_Bean)request.getAttribute("brBean");
    Date rent_day = brBean.getRent_day();
    Calendar cal = Calendar.getInstance();
    cal.setTime(rent_day);
    cal.add(Calendar.DATE, 14);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

 function calDate(){
     var mrent_back_day = $("#mrent_back_day").val();
     var back_day =$("#back_day").val();

     date1 = mrent_back_day.split("-");
     date2 = back_day.split("-");

     var time1 = new Date(date1[0],date1[1]-1,date1[2]).getTime();
     var time2 = new Date(date2[0],date2[1]-1,date2[2]).getTime();
     var relayday = (time1-time2)/(1000*60*60*24);

     $("#relayday").prepend(relayday);

 }