Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get time difference relative to official business hour
    text
    copied!<p>I have to show total working hour of employee relative to official business hour. if a task is started then start time and end time entered in to database.</p> <p>Entry something like:</p> <pre><code>start time= `2013-10-18 16:06:16.840` end time=`2013-10-22 16:09:09.760` </code></pre> <p>Working hour is configurable as per organization.</p> <p><strong>working hour=</strong> <code>7.45 (7 hour and 45 minutes) =1 day</code></p> <p>if someone is worked more then working hour, It consider under extra work and consider as extra time.</p> <p>I need output according to user worked for a day. Output for one day like</p> <pre><code>7.45 hour then 1 days 7.50 hour then 1 days and 5 minute 14.50 hour then 1 days, 7 hour and 5 minutes </code></pre> <p>I have done below coding. It is not giving as much as acurate result of my expect.</p> <p>What I done:</p> <pre><code>1) take difference of two days 2) instead of using 24 hour, I used business hour. </code></pre> <p><strong>Code:</strong></p> <pre><code> public static long[] getTimeDifference(Date d1,Date d2,int holiday,String businessHour) { long hour=0; if(businessHour.indexOf(".")!=-1) { hour=Long.valueOf(businessHour.substring(0,businessHour.indexOf(".")));///check for hour } else { hour=Long.valueOf(businessHour); } long[] time=new long[3]; long diff = d2.getTime() - d1.getTime(); //double diffSeconds = diff / 1000 % 60; long diffMinutes = diff / (60 * 1000) % 60; long diffHours = (diff / (60 * 60 * 1000) % hour); long diffDays = (diff / (hour * 60 * 60 * 1000)); diffDays=diffDays-holiday; time[0]=diffDays; time[1]=diffHours; time[2]=diffMinutes; return time; } </code></pre> <p><strong>output:</strong> 11 days: 05 hours: 02 minutes</p> <p>I am not included minute logic yet, how can I do implementation? I don't have idea. I am confuse with this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload