cancel
Showing results for 
Search instead for 
Did you mean: 

Time Comparison and Subtracting

Former Member
0 Kudos

I have a requirement regarding time like i need to compare two time datatype fields, like Start time and End time, End time should not be greater than Start Time. Also Lunch break field will be entered in mins. So, now I need to display in a field Working = Start-End-Lunch. How can I subtract Time from Time and also Compare in Webdynpro Java

Accepted Solutions (1)

Accepted Solutions (1)

Sharathmg
Active Contributor
0 Kudos

Its more w.r.t. plain old Java.

Look up in Java to use the Date/Time classes to subtract the times.

Check this link for some clue into time subtraction in Java.

http://www.mkyong.com/java/how-to-calculate-date-time-difference-in-java/

Regards,

Sharath

Former Member
0 Kudos

Thank you Sharath. Its working

Former Member
0 Kudos

Hi Sharath,

As you suggested I can subtract two times, but lunch also needs to be subtracted which is of integer type i.e. the user will enter in mins. Now, how can I subtract lunch time also from two times. Can you suggest.

junwu
Active Contributor
0 Kudos

please spend some time looking at the date time api....

Sharathmg
Active Contributor
0 Kudos

It should be simpler as the time to be subtracted should also be cast into Date class.

Check for converting integer to Date/Time. Then, subtract it similar to previous step.

Regards,

Sharath

Former Member
0 Kudos

Integer is not converting into Date/Time. Can you suggest another way.

Sharathmg
Active Contributor
0 Kudos

Try to use the Calendar Instance object to subract times.

Check this link for your ref:

Add/Subtract Hours from Date with Calendar | Examples Java Code Geeks

Regards,

Sharath

Answers (0)