• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

convert TIME to Millisec

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can i get a link or the code to change a user input time format to milliseconds. for example a user has put 08:00 or 20:00 (24 hour clock), i need to convert the time to Milliseconds. Thanks in advance for any help.

Moreover can i also get some hints about executing a code for a specific amount of time and after that time the application stops.for example the application runs for 1 hour and stops after 1 hour.thanks again.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Zaafir]: can i get a link or the code to change a user input time format to milliseconds

Milliseconds since... what? The standard choice in Java (inherited from the Unix world) is to measure milliseconds since Jan 1, 1970 GMT. This is used in the java.util.Date class and associated classes like the evil Calendar and GregorianCalendar classes. Also less evil (less needlessly obfuscated) classes, like SimpleDateFormat. The last is probably what you want for parsing user input and converting it to a Date. For example:


As for how to get your code to execute for an hour... well, that depends. Does your code normally complete in less than an hour, and you're just looping repeatedly to keep it alive? Or does your code sometimes take more than an hour to complete its basic tasks, and you need to be able to kill it if it runs too long?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic