•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 423,540 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,128 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 362 | Replies: 2
![]() |
•
•
Join Date: Jan 2008
Posts: 13
Reputation:
Rep Power: 1
Solved Threads: 0
please help me compute for the time..
i have extracted different time values from a database, i stored it in a String since i don't know which data type to use. this values came from a DataList in a variable named jamTime..
then i extracted the time using:
String startTime = jamTime.getString("start_date_time");
String endTime = jamTime.getString("end_date_time");
i want to get the difference between this two time. the value of these variables were:
startTime = "02:33:45"
endTime = "02:36:56"
and i need to display their difference in seconds.
please help me how to compute for this if there is such format or parsing method to convert my string into a value which can be manipulated with arithmetic functions.
thanks... feel free to ask me questions if i did not explain it quite well...
i have extracted different time values from a database, i stored it in a String since i don't know which data type to use. this values came from a DataList in a variable named jamTime..
then i extracted the time using:
String startTime = jamTime.getString("start_date_time");
String endTime = jamTime.getString("end_date_time");
i want to get the difference between this two time. the value of these variables were:
startTime = "02:33:45"
endTime = "02:36:56"
and i need to display their difference in seconds.
please help me how to compute for this if there is such format or parsing method to convert my string into a value which can be manipulated with arithmetic functions.
thanks... feel free to ask me questions if i did not explain it quite well...
first of all, you must understand that the String class is not meant to compute things with. If you really want to compare dates, you might want to check out the classes
'Date', or, propably even better: 'GregorianCalendar'. By using those, it should be no real problem determining the difference between the two.
Since 'Date' has got a number of deprecated methods, I'd advice you to use GregorianCalendar
or, you could also use this String objects, seperate them in substrings, convert these to integers and use those to calculate the difference, but I think comparing dates is still a better choice than to compare numbers.
'Date', or, propably even better: 'GregorianCalendar'. By using those, it should be no real problem determining the difference between the two.
Since 'Date' has got a number of deprecated methods, I'd advice you to use GregorianCalendar
or, you could also use this String objects, seperate them in substrings, convert these to integers and use those to calculate the difference, but I think comparing dates is still a better choice than to compare numbers.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- calculate time complexity of the algorithm (Computer Science and Software Design)
- about time complexity (Software Developers' Lounge)
- Time Difference with precision (C)
- how to compute the time cmplexcity (C++)
- Time Complexity ? (Computer Science and Software Design)
- computation time for arithmeic operations (C)
- help on using StringTokenizer to read and compute multiple lines from text (Java)
- Time display program (C++)
Other Threads in the Java Forum
- Previous Thread: who can help me in java?
- Next Thread: Issues with JOGL


Linear Mode