| | |
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: 985
Reputation:
Solved Threads: 145
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
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary bluetooth character chat class classes client code component consumer csv database desktop draw eclipse error event exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javac javaee javaprojects jmf jni jpanel julia linked linux list loop map method methods mobile netbeans newbie objects online oracle oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion robot rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time tree ubuntu update windows





