943,546 Members | Top Members by Rank

Ad:
Dec 13th, 2008
0

Help with java calendar

Expand Post »
I have a basic problem i dont know where the error lies.
i can create a class Persoon and fill in all its values before its created .
but for some reason when i call up the information i get the current Date as the birthdate and not what i have entered.

when i enter the birtdate directly into the class via its method after it has been created it will rmember it.

the all the geboorte things are related to the birthDate tho you can probably see by the use of calendar

can anyone see why or tell me while?
maybe i dont understand the calendar api .
but we were forced to use calendar or date
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. /**
  2.  * de persoon maken, hier word alles gemaakt wat
  3.  * docent en student gemeen hebben.
  4.  */
  5. import java.util.*;
  6.  
  7.  
  8. public class Persoon
  9. {
  10. /**
  11.   *variabelen instantieren
  12.   */
  13. private String naam;//voor methode setNaam
  14. private String geslacht;//voor methode setGeslacht
  15. private int leeftijd;
  16. private int geboorteDag;
  17. private int geboorteMaand;
  18. private int geboorteJaar;
  19. private Calendar geboorteInformatie = new GregorianCalendar();
  20.  
  21. /**
  22.   * Constructor voor objecten van de class persoon
  23.   */
  24. //eigenschappen van persoon construeren
  25. public Persoon(String naam, String geslacht, int geboorteDag, int geboorteMaand, int geboorteJaar )
  26. {
  27. this.naam = naam;
  28. this.geslacht = geslacht;
  29. this.geboorteDag = geboorteDag;
  30. this.geboorteMaand = geboorteMaand;
  31. this.geboorteJaar = geboorteJaar;
  32. }
  33.  
  34. /**
  35.   * methoden voor persoon
  36.   */
  37.  
  38. //methode maken voor namen
  39. public String setNaam(String voornaam, String achternaam)
  40. {
  41. naam = voornaam + " " + achternaam;
  42. return naam;
  43. }
  44.  
  45. //methode maken voor het geslacht
  46. public String setGeslacht(String manOfVrouw)
  47. {
  48. geslacht = manOfVrouw;
  49. return geslacht;
  50. }
  51.  
  52. //methode maken voor geboortedatum
  53. public void setGeboorteDatum(int geboorteDag, int geboorteMaand, int geboorteJaar)
  54. {
  55. geboorteInformatie.set(geboorteJaar,geboorteMaand,geboorteDag);
  56. }
  57.  
  58. private int getGeboorteDag()
  59. {
  60. geboorteDag = geboorteInformatie.get(Calendar.DAY_OF_MONTH);
  61. return geboorteDag;
  62. }
  63.  
  64. private int getGeboorteMaand()
  65. {
  66. geboorteMaand = geboorteInformatie.get(Calendar.MONTH);
  67. return geboorteMaand;
  68. }
  69.  
  70. private int getGeboorteJaar()
  71. {
  72. geboorteJaar = geboorteInformatie.get(Calendar.YEAR);
  73. return geboorteJaar;
  74. }
  75.  
  76. public void print()
  77. {
  78. System.out.println("Jaar: " + geboorteInformatie.get(Calendar.YEAR) +" Dag: "+ geboorteInformatie.get(Calendar.DAY_OF_MONTH)+" Maand: "+ geboorteInformatie.get(Calendar.MONTH));
  79. System.out.println("geslacht: " + geslacht);
  80. System.out.println("Naam: " + naam);
  81. }
  82.  
  83. //checken welke persoon ouder is
  84. public boolean ouderDan(Persoon deAnder)
  85. {
  86. return geboorteInformatie.before(deAnder.geboorteInformatie);
  87. //als de geboorte van de eerste persoon eerder was dan de ander dan zal er true uitkomen
  88.  
  89. }
  90. }
Last edited by Sereal_Killer; Dec 13th, 2008 at 5:33 pm. Reason: added code cause i forgot
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Sereal_Killer is offline Offline
17 posts
since Nov 2008
Dec 13th, 2008
0

Re: Help with java calendar

IGNORE PLEASE , OR DELETE .
Put in wrong forum and alrdy created a new one
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Sereal_Killer is offline Offline
17 posts
since Nov 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: popups without html
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Vertical Scrolling Gallery?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC