| | |
converting individual date entry to long
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
i just dont know how to convert this.
i have three integers for month, date and year. year is a two digit input.
i want to convert these three into one variable type long.. but i dont know how to do it.
i tried adding the three integers, but i get weird results.
i want to do this because i want to compare user input date into the current date. [actually, it's an age calculator.]
waah, help would be greatly appreciated.
i have three integers for month, date and year. year is a two digit input.
i want to convert these three into one variable type long.. but i dont know how to do it.
i tried adding the three integers, but i get weird results.
i want to do this because i want to compare user input date into the current date. [actually, it's an age calculator.]
waah, help would be greatly appreciated.
a joke.
•
•
Join Date: Apr 2008
Posts: 1,020
Reputation:
Solved Threads: 151
Yes, in fact you can code it in binary machine code if you want. But why? Someone has gone to a great deal of trouble to write and test a class that does exactly what you want - why re-invent the wheel?
IMHO a good Java programmer isn't just soneone who knows the language, it'ssomeone who knows and uses the API.
IMHO a good Java programmer isn't just soneone who knows the language, it'ssomeone who knows and uses the API.
i can't get the comparison to work.
for example, if i enter 1-22-1991, this returns 18.
if i enter 9-23-1991, this returns 17.
BUT if i enter 8-10-1991, this returns 17!
ALSO if i enter 8-9-1991, this returns 17!
i just can't fugure out what's wrong.
help.
java Syntax (Toggle Plain Text)
birthDate.set(yyyy, mm, dd); age = currentDate.get(Calendar.YEAR) - birthDate.get(Calendar.YEAR); if(currentDate.compareTo(new GregorianCalendar(currentDate.get(Calendar.YEAR), birthDate.get(Calendar.MONTH), birthDate.get(Calendar.DAY_OF_MONTH))) < 0) { age--; }
for example, if i enter 1-22-1991, this returns 18.
if i enter 9-23-1991, this returns 17.
BUT if i enter 8-10-1991, this returns 17!
ALSO if i enter 8-9-1991, this returns 17!
i just can't fugure out what's wrong.
help.
a joke.
![]() |
Similar Threads
- Converting int(10) to Date Format (PHP)
- how to convert string values to date and compare them while using an array (JSP)
- Fixes for Specific Infections (Viruses, Spyware and other Nasties)
- Guestbook help. Post in two different spots. (Perl)
- editing the appearance of entries in a guestbook (HTML and CSS)
- Logic to Convert Days From 1800 to a Date (Month, Day, Year) (C++)
- help with polymorphism and inheritance...getting null values (Java)
Other Threads in the Java Forum
- Previous Thread: java and vc++ linking
- Next Thread: Motion targetting in java
Views: 346 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Java
-xlint android animated api appinventor apple applet application arguments array arrays automation bi binary blackberry bluetooth chat class classes client code compile compiler component database draw eclipse error event exception file fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui helpwithhomework html ide image input integer j2me java javaprojects jetbrains jmf jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie notdisplaying number object oracle page print problem program programming project qt recursion scanner screen server set size sms socket sort spamblocker sql string swing system test threads time transfer tree variablebinding windows xor






