Hours Calculation

Hi,
Am new to Java programming... am at a loss with this!!
I would like to count the no. of hours between two dates (of type Calendar).
Anyone has any idea what to do?

Try this,
import java.util.Date;
import java.text.DateFormat;
class DateTest {
     public static void main(String h[]) throws java.text.ParseException {
          Date dt1 = new Date("01-Jan-2000");
          Date dt2 = new Date("02-Jan-2000");
          long dt1Milli = dt1.getTime();
          long dt2Milli = dt2.getTime();
          int diff = (int)(dt2Milli - dt1Milli);
          System.out.println("Diff in Hours : "+diff/1000/60/60);
}You need to introduce the validations.
Sudha

Similar Messages

  • Daily working hours calculation but Half an hour flexi before start of planned time & shortfall hours calculation

    Dear All,
    I want to calculate daily working hours but Half an hour flexi before start of planned time & shortfall hours calculation if a person didn't completed 9 hours job.
    We have different types of DWS, PWS & WSR for different PS/PSA & EG/ESG groupings.
    We have a requirement for Executives/Officers (E0-E8/ S1-S2) for only one PSA (1100) for only one DWS(GFLX). In this requirement I want to calculate daily working hours but Half an hour flexi before start of planned time & shortfall hours calculation if a person didn't completed 9 hours job.
    Please see the requirement and my configured DWS and PCR's in detail with example and suggest me the solution:-
    Overview
    I want to calculate (Please take the reference from DWS screenshot)
    daily working hours, but starting from first Begin Tolerance Time
    Shortfall of hours if 9 hours not completed, but again starting from first Begin Tolerance Time, although employee has come before Begin Tolerance Time
    I've configured one DWS as below,
    Requirement:-
    The planned shift timings is 9:30 - 18:30. Employees should work and complete 9 hrs in a day, but this 9 hours should be counted only from 9:00 (i.e. Begin tolerance time). It means. In time should not consider before 9:00.
    1. Suppose 1st day employee punch In time is 9:00 then he has to work up to 18:00, then only 9 hours of working will be completed & no shortfall will be calculated.
    In above case, if Out time is 17:00 then shortfall will be calculated 1.0 hours, because his working hours will be counted 8 hrs only.
    2. Suppose 2nd day employee punch In time is 9:45 then he has to work up to 18:45, then only 9 hours of working will be completed & no shortfall will be calculated.
    In above case, if Out time is 18:00 then shortfall will be calculated 0.75 hours, because his working hours will be counted 8.25 hrs only.
    3. Suppose 3rd day employee punch In time is 8:30 then he has to work up to 18:00, then only 9 hours of working will be completed & no shortfall will be calculated. (In between 9:00 - 18:00 ). Here In time is 8:30 but system should consider and count from 9:00.
    In above case, if Out time is 17:30 then shortfall will be calculated 0.5 hours, although he has worked 9 hrs.
    4. Suppose 4th day employee punch In time is 10:11 then he will be marked as Late Come(as per DWS) and then he has to work up to 19:11, then only no shortfall will be calculated, because he completed 9 hours.
    Now the below PCR is calculating Daily Working Hours,
    Now the below PCR is calculating Late Coming Hours,
    Overview
    I know that use of begin tolerance time is different in from my requirement. Please guide me if this DWS configuration will not work.
    As of now system is able to calculate Daily Working Hours (but not from the begin tolerance time), Late coming days and Late coming hours, but shortfall is not getting calculate properly.
    Please give me the idea how to write PCR for these requirement, I know that my ZDHR PCR (Daily Working Hours) needs to change or replace to fulfill this requirements.
    If you want any other details please let me know.
    Best Regards,
    Deepak

    Hi Sankarsan,
    After changing the function PTIP and I used GEN in PAR2, because in PAR3 error was coming.
    After the changes PCR is processing as below for three different IN time :
    1. when IN time is 8:45
    and in this case, ZES table No Time type is showing which is wrong because he worked from 8:45 to 18:30 it means 9:30 hours (calculation should start from 9:00 am).
    2. when IN time is 9:15
    and in this case, ZES table Time type 9002 is showing 9.25 hours which is correct because he worked 9.25 hours.
    3. when IN time is 10:30
    and in this case, ZES table Time type 9003 is showing 9.00 hours which is wrong because he worked only 8 hours.
    Pls suggest.
    Best Regards,
    Deepak

  • Work Hours Calculation - ERROR

    Hi All,
    I'm having difficulty with the Work Hours Calculation in Project. It seems that when the number of hours within a subtask group exceeds 1000 hours, the display returns 1 hour. Whilst the Project Statistics for cost are correct, the number of hours is wrong!
    Has anyone seen this error before and can help?
    I would post piccy but Microsoft wont allow that yet. 

    Thanks for the reply Guillaume,
    The Project version in question is 2007 SP3.
    The issue occurs on every project that I am currently handling so it is causing me some troubles at the moment. I have even tried using the example you gave and it still does not work correctly.
    Unfortunately until my account is approved I cannot post pictures however the following is the equivalent to your project above:
    Project 1 67 days
    Mon 15/12/14 Tue 17/03/15
    1 hrs
    Summary
    67 days Mon 15/12/14
    Tue 17/03/15 1 hrs
    A 50 days
    Mon 15/12/14 Fri 20/02/15
    400 hrs A
    B 67 days
    Mon 15/12/14 Tue 17/03/15
    536 hrs B
    C 30 days
    Mon 15/12/14 Fri 23/01/15
    240 hrs C
    D 10 days
    Mon 15/12/14 Fri 26/12/14
    80 hrs D
    Many thanks,
    Jon

  • Daily working Hours Calculation

    Dear All
           Time Management - >Work Schedules->Set Work Schedule rules and work schedule
           How to calculate the Daily working hours if my shift time is as given below
      Night  00:25 to  Morning 07:30
    My break time is between 3:30 to 4:00
    So my actual working hours is  6:35 hours (6 hrs and 35 min).
    What i need to enter in the Daily working hours, whether 6.35 or 6.58 (0.25/15*35)?
    regards
    Suresh S

    Hi,
    First create a break shedule from 3:30 to 4:00 AM and specify if paid or unpaid.
    Use this break schedule while creating daily work schedule. Specify the timings of 0:25 as start in planned working time, the end time will be calculated automatically.
    Use this DWS in your PWS which you in turn use while setting WSR as you stated above. The Daily Working time will be automatically taken from DWS. And I think it should be 6:35 hrs.
    cheers
    Ajay

  • Code for employee worked hours calculation

    Hello everyone,
    I need some help with an ABAP code:
    I have records coming in with Employee ID, Date and Worked hours along with some other fields.
    I need to look up the employee id aginst another table to figure out if the employee depends to a particular state or not and the date is holiday or not from different table.
    Also I would like to see if worked hours are more than 8 and put the extra hours into a differemt field for calculating if the total hours in a week exceed 40.
    Can you please help with this code?
    Thanks,
    Raj

    >
    Raj Coppar wrote:
    > Hello everyone,
    >
    > I need some help with an ABAP code:
    >
    > I have records coming in with Employee ID, Date and Worked hours along with some other fields.
    >
    > I need to look up the employee id aginst another table to figure out if the employee depends to a particular state or not and the date is holiday or not from different table--- u can use FM BKK_CHECK_HOLIDAY to find out the given date is holiday or not ? Also I would like to see if worked hours are more than 8 and put the extra hours into a differemt field for calculating if the total hours in a week exceed 40.
    >
    > Can you please help with this code?
    >
    > Thanks,
    > Raj

  • CATS hours calculation error.

    Hi All,
    I'm having the following issue with CATS, using the transaction CAT2, I created 3 time entries:
    08:00:00     08:25:00     duration 0.42 hours
    08:25:00     09:25:00     duration 1 hour
    09:25:00     12:00:15     duration 1.83 hours   This value is an error because it should be 2.58 hours, and I don't know why it is calculating this period in an incorrect way, and the other 2 entries in a correct way.
    Thanks in advance.

    Hi Fernando,
    Please go to V_T550P and check whether there are any breaks defined for that time interval.
    To check break schedule for your daily work schedule check table V_T550A.
    Regards,
    Dilek
    Edited by: Dilek Ersoz Adak on Feb 15, 2010 4:04 PM

  • Very Simple Overtime Hours Calculation

    I have no experience with JavaScript and need help with a calculation for a simple Acrobat time sheet.
    I have a timesheet form that adds and populates a "Total Hours" box, and I would like to automatically populate a "Regular Hours" box and an "Overtime Hours" box (based on a standard 40 hours week).
    ex: if "Total Hours" = 55, "Regular Hours" should read 40, "Overtime Hours" should read 15.
    ex: if "Total Hours" = 30, "Regular Hours" should read 30, "Overtime Hours" should read 0.

    Use this code as the custom calculation code of Regular Hours:
    event.value = +this.getField("Total Hours").value > 40 ? 40 : +this.getField("Total Hours").value;
    Use this code as the custom calculation code of Overtime Hours:
    event.value = +this.getField("Total Hours").value > 40 ? (+this.getField("Total Hours").value - 40) : 0;

  • How to create work schedules for hours calculation

    HI Experts,
    We are working on payroll process which has to be consider  the number of working hours  for calculation.
    Now we need to generate the workschedule based on hours.
    What is the process of creation of workschedule  with respect to the consideration of number of hours.
    Please share your ideas on creation of workschedules with respect to number of hours.
    Thanks and regards,
    Sairam.

    Dear Siki,
    I want to create a new work schedule for the employees for whom the  salary calculation to be based on  working hours.
    Is there any preacautions to be maintained for the generation of work schedules in these directions.
    Regards,
    Sairam.

  • Labour hour calculation in confirmation

    Hi,
    I have a scenario where one employee is assigned common to two capcities of one work centers.
    While taking up production of two products in a same work center in two capacities how the labour hour would be calculated. Example:
    Work center : W001, No.Of Individual Machine Capacities -2
                                   No.Of Individual Labour Capacities -1.
    Two Production orders released in work centers for the same time. One order is run for 6 hrs in a shift,another order is run for 8 hrs in the same shift(Means upto 6hrs both were in parallel,then last 2 hours only one order was ruuning),Labour performs both the orders in parallel as he manages both machines. How much is the labour time to be entered in CO11N confirmation for each order.

    Hi,,
    U can see the labor cost.But prior to that u have to mention the workcenter in the order and in work center u have to mention capacity of work center and mention the formula for cost calculation cost.all this have to first configure in work center prior to use in any order then order give u cost of the Labor according to Ur Order time confirmation your timing should be 6 hrs and 8 hrs as there are two order we want to calculate the cost of each order.
    Regards,
    R.Brahmankar

  • Employee overtime hours calculation

    Hello everyone,
    I need some help with an ABAP code:
    Records coming in with Employee ID, Date and Worked hours along with some other fields. There will be multiple records with the same Employee id.
    I would like to have a count for all the hours for that particular employee and keep a track if it goes above 40 hours.
    I also need to keep a track of hours in a particular day to see if they are above 8 hours.
    Can you please help with this code?
    Thanks,
    Raj

    Hi Raj....
    As we are not having such a kind of data....
    I tried this with appending itab...
    check this code....
    data: begin of itab occurs 0,
          empid(4),
          whrs(2) type n,
          flag1,
          exday(2) type n,             <---to capture the extra working hours of the day
          flag2,
          exemp(2) type n,             <----to capture the extra working hours of the employee
          date like sy-datum,
          end of itab.
    data: sum(3) type n.
    itab-empid = '1111'.
    itab-date = sy-datum.
    itab-whrs = 10.
    append itab.
    clear itab.
    itab-empid = '1111'.
    itab-date = sy-datum.
    itab-whrs = 80.
    append itab.
    clear itab.
    itab-empid = '1111'.
    itab-date = sy-datum + 1.
    itab-whrs = 10.
    append itab.
    clear itab.
    itab-empid = '1112'.
    itab-date = sy-datum.
    itab-whrs = 10.
    append itab.
    clear itab.
    itab-empid = '1112'.
    itab-date = sy-datum + 1.
    itab-whrs = 2.
    append itab.
    clear itab.
    itab-empid = '1112'.
    itab-date = sy-datum + 1.
    itab-whrs = 10.
    append itab.
    clear itab.
    itab-empid = '1113'.
    itab-date = sy-datum + 1.
    itab-whrs = 10.
    append itab.
    clear itab.
    itab-empid = '1113'.
    itab-date = sy-datum + 2.
    itab-whrs = 7.
    append itab.
    clear itab.
    itab-empid = '1113'.
    itab-date = sy-datum + 1.
    itab-whrs = 8.
    append itab.
    clear itab.
    loop at itab.
      at end of date.
        if itab-whrs > 8.
          itab-flag1 = 'X'.
          itab-exday = ( itab-whrs - 8 ).
          modify itab.
          endif.
        sum.
        sum = sum + itab-whrs.
      endat.
      at end of empid.                         <-----change code to avoid stars due to end of ..event
        if sum > 80.
          itab-flag2 = 'X'.
          itab-exemp = sum - 80.
          modify itab.
          clear itab.
         endif.
       clear: sum.
       endat.
      endloop.
    loop at itab.
    write:/ itab-empid,
            itab-date,
            itab-whrs,
            itab-flag1,
            itab-exday,
            itab-flag2,
            itab-exemp.
    endloop.
    Thanks,
    Naveen.I

  • Labor hours calculation inconsistency

    hi
    I am trying to get a std. price for two new models, however there is an inconsistency when the labor cost is calculated.
    in CK11N .(CK13N) ( both plan estimations are in the same cost center )
    (under cost of goods manufactured -- direct labor)
    For one product cost estimation  labour cost is showing as overall cell content and level cell content ,
    where as another product cost estimation  showing overall cell content, lower level cell content and level cell content
    We would like to know from where this lower level has come for one product cost estimation in labor cost .
    expecting a reply ASAP
    thank you
    kanna

    dear rajesh
    when we go into CK13N we will get display material cost estimate under costs tab
    see  cost of goods manufactured and double click on that we wll get cost components for materials in that go to direct labor and select and see the details ,
    we will get group description under this
    1) For one product cost estimation labour cost is showing as overall cell content and level cell content ,
    2) where as another product cost estimation showing overall cell content, lower level cell content and level cell content
    We would like to know from where this lower level has come for one product cost estimation in labor cost .
    thanks and regards

  • Working Hours Calculation possible ?

    Anyone know if there is a FM to calculate the Working Hours that exist between two dates.
    For instance ...entire year may = 2080 working hours.  User wants to know Working hours between
    any two dates ....  like....   July 1, 2007 and   May 5, 2008.....
    Thanks
    MPersson

    Rob,
    Thats a valid point.  In my case I am only determining the total possible working hours for a budget report.
    Prior to this, the supervisors were simply using a full year of 52 weeks x 40  hrs = 2080.  This report takes
    the hours captured on the CATS timesheet and processes them accordingly. So Holidays and any leave
    time is identified within the program code and handled then.
    Thanks
    MPersson

  • MINS  to HOURS Calculation

    Hi,
    We have a Key Figure of Quantiy type. And it has units as HR, Mins & std.
    Now i want to Convert all minutes into HR. What is the best way ? I have to check in Units for MIN then
    do the calculation. Can we do Update routine or in report ?
    -Sonti-

    Hi,
    Can be done at Transformation Rule Details -- Formula --- Minutes / 60 will give you HR
    You can Even create A Formula at Query Designer too -- formula -- Total Minutes / 60 = 'n' hrs.
    Hope it helps.

  • Labour Hour Calculated In BOM

    Hello,
    I have removed the routing from my PO and also from the routing tree for that materials,even after removing some of the Partial Stage labour hours are Picking??,How it is Picking the labour hours for the removed routing,but i have found few materials issued in that stages..whether the Labour hours liked with the materials??Pls clear...
    Whether Labour hours are assigned to the materials or for the Process,if it is for the Process then how the LAbour hour is comming while doing cost analysis as the full material is not consumed in that Particular stages.
    regards
    Nandhu

    Hello Abbas,
    I did not completely understand your question but confirming on the labor item for BOM.  It should be defined in the Item Master of type Labor.  In the Inventory data tab set the valuation method to Standard and define a cost for the labor.  A labor item in the BOM definition should be defined with issue method Backflush.
    Suda

  • OT Hours Calculation

    Hi All,
    As per requirement  OT upto 7 Minute will not be paid. 8 Minute and above will be taken as 15 Min OT.
    We have decided to use the dividing factor .25 as constant to achieve.
    Minute Entered in 2002           =        8 Min
    System Stores in HRs 2002    =      0.13 Hrs
    Devide System Hrs / .25 ( Constant)     =      0.52
    Round to Zero Decimal                            = 1
    Devide Rouded result X .25                           = 0.25
    How we can keep this in Rule.
    Regards,
    Kamal Rawal

    Hi
    The below is your rule formate
    OUTTPPRTYP
    0545
    HRS=PNUM
    ADDDB9000Z
    HRS/CZST25
    or HRS/0.25
    ADDDB5007Z
    Leave
    This rule should work for u and now in TM04 call after P2002 using PTIP Function
    PTIP ZTES
    The same way we written the rule but it isnot reading and where we are militating and where we are using ROUND operation.
    Tell me where we have to call this rule in schema.  We called this one as u said, but it is not reading because IF and End IF is there.
    Please suggest us.
    Regards,
    Kamal Rawal

Maybe you are looking for

  • Partial payment for down payment request

    Dear All I have posted a 1000 INR down payment request by F-37. However, the customer only pays me for 700 INR. If i use F-29 to record the downpayment and try to link this 700 INR to the original down payment request then the system does not allow m

  • OIM 11G : Selecting Multiple RO's in Single "Self Request Resource" Failing

    Hello Everyone, OIM 11G : End User "Self Request Resource" failing when user selects 2 or more resources in a Single Self Request Resource Request 1) On OIM 11G, I have created 2 resource objects, workflow, process forms. 2) Created the separate requ

  • AU CC: VST 64-Bit Plug-In Effects?

    Hey guys, how do we get our 64-Bit Plug-In Effects into the VST Effect Racks in Audition CC?

  • Límite de impresión en Photoshop Element  3 y 4

    Escribo este comentario solo para compartir algo que he descubierto sobre Photoshop Element 3 y 4 y lo que no encontraba explicación. No tiene importancia pero es curioso. He estado utilizando Photoshop Element 3 hasta hace un mes que me han regalado

  • IPod nano 4G- difficulty syncing

    When I plug in my iPod it appears in the left column as it should, and charges as it should, etc. However, when I select it the screen is just white with iStore in grey in the middle, as though I have selected iStore and not iPod. I cannot get it to