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

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?
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic