Javaでは、2つの同じ日の間隔の時間数を計算し、小数点以下を保持します.


SimpleDateFormat sdf=new SimpleDateFormat("hh:mm");
		    Date time = sdf.parse(activityVO.getActivity().getActiveStartTime());
		    Date time2 = sdf.parse(activityVO.getActivity().getActiveEndTime());
		    sdf = null;
			
			Calendar instance = Calendar.getInstance();
			instance.setTime(time);
			long timeInMillis1 = instance.getTimeInMillis();
			instance = null;
			time = null;
			
			Calendar instance2 = Calendar.getInstance();
			instance2.setTime(time2);
			long timeInMillis2 = instance2.getTimeInMillis();
			instance2 = null;
			time2 = null;
			
			double hours = (timeInMillis2 - timeInMillis1)/1000/60/60.0;
			DecimalFormat df = new DecimalFormat("##.#");
            String dff=df.format(hours);
            df = null;