I'm finalizing a worksheet project for an accounting and it's my first project so I still do not experience manipulating date and time in java and database without further ado:
I need only and exclusively to make the following account through the system:
Time Check In Check Out Check Out Check Out Check Out
08:00 11:00 1:00 PM
Totalizing 3 hours worked in the morning and 4 hours worked in the afternoon. I would like to know the best way to manipulate and make this account, I thought of turning into long more I could not finish the ideas. I know that by far this is a Minimum, Complete and Verifiable example, but I like to figure out how to do it and then turn around.
After watching several video lessons, I did the form below, so I can find the duration between the hours of entry and exit, but I really thought it was a gambiarra, who can help me improve this code, turn 23:00 in two integer attributes one of 23 and another one with value 00 does not seem to be right for me, thank you!
public void teste(){
int teste1 = (Integer.parseInt(jTextFieldHora1.getText().substring(0,2)));
int teste2 = (Integer.parseInt(jTextFieldHora1.getText().substring(3,4)));
int teste3 = (Integer.parseInt(jTextFieldHora2.getText().substring(0,2)));
int teste4 = (Integer.parseInt(jTextFieldHora2.getText().substring(3,4)));
LocalTime time1 = LocalTime.of(teste1,teste2);
LocalTime time2 = LocalTime.of(teste3,teste4);
System.out.println(ChronoUnit.MINUTES.between(time1, time2));
}