Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

start time and end time

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i m using thing code to check start time and end time of user is this a correct approach ?





       OffsetTime currentTime = OffsetTime.now();
       
       
       OffsetTime setTime=OffsetTime.parse("04:00:00.000+05:00");
       
       System.out.println(currentTime);
       
             System.out.println(setTime);
       
       System.out.println(currentTime.isBefore(setTime));

       System.out.println(currentTime.isAfter(setTime));
       
       
       String request=JOptionPane.showInputDialog(null, "I want to quit work");
       
       if(request.equals("y")){
       
       if(currentTime.isAfter(setTime))
       
               System.out.println("you are granted to leave");
       
       
       
       }
       else if(currentTime.isBefore(setTime)){
        System.out.println("its working hours");
       
       }
 
 
Master Rancher
Posts: 4188
57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That seems reasonable so far.  Are you seeing any problem?  Is there something specific you're wondering about?  

Is the time zone something you care about here?  Do you need to be comparing people in different time zones?  I feel like if you're talking about "working hours", you might just want to use LocalTime, not OffsetTime.  Then you can ignore time zones.  But that's just a guess.
 
Rancher
Posts: 4739
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

code to check...


What does "to check" mean?  What tests is the code supposed to make? Should there be any results from the checks?

Please edit the code and wrap it in code tags:  select code and press Code button
 
obaid abbassi
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
everything is ok how to put am and pm in this  time to compare because this code does not recognizing whether its morning 4:00  or evening 4:00
 
"How many licks ..." - I think all of this dog's research starts with these words. Tasty tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic