Help with java calendar
Please support our JavaScript / DHTML / AJAX advertiser: Programming Forums
Thread Solved
![]() |
•
•
Posts: 8
Reputation:
Solved Threads: 0
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
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
/**
* de persoon maken, hier word alles gemaakt wat
* docent en student gemeen hebben.
*/
import java.util.*;
public class Persoon
{
/**
*variabelen instantieren
*/
private String naam;//voor methode setNaam
private String geslacht;//voor methode setGeslacht
private int leeftijd;
private int geboorteDag;
private int geboorteMaand;
private int geboorteJaar;
private Calendar geboorteInformatie = new GregorianCalendar();
/**
* Constructor voor objecten van de class persoon
*/
//eigenschappen van persoon construeren
public Persoon(String naam, String geslacht, int geboorteDag, int geboorteMaand, int geboorteJaar )
{
this.naam = naam;
this.geslacht = geslacht;
this.geboorteDag = geboorteDag;
this.geboorteMaand = geboorteMaand;
this.geboorteJaar = geboorteJaar;
}
/**
* methoden voor persoon
*/
//methode maken voor namen
public String setNaam(String voornaam, String achternaam)
{
naam = voornaam + " " + achternaam;
return naam;
}
//methode maken voor het geslacht
public String setGeslacht(String manOfVrouw)
{
geslacht = manOfVrouw;
return geslacht;
}
//methode maken voor geboortedatum
public void setGeboorteDatum(int geboorteDag, int geboorteMaand, int geboorteJaar)
{
geboorteInformatie.set(geboorteJaar,geboorteMaand,geboorteDag);
}
private int getGeboorteDag()
{
geboorteDag = geboorteInformatie.get(Calendar.DAY_OF_MONTH);
return geboorteDag;
}
private int getGeboorteMaand()
{
geboorteMaand = geboorteInformatie.get(Calendar.MONTH);
return geboorteMaand;
}
private int getGeboorteJaar()
{
geboorteJaar = geboorteInformatie.get(Calendar.YEAR);
return geboorteJaar;
}
public void print()
{
System.out.println("Jaar: " + geboorteInformatie.get(Calendar.YEAR) +" Dag: "+ geboorteInformatie.get(Calendar.DAY_OF_MONTH)+" Maand: "+ geboorteInformatie.get(Calendar.MONTH));
System.out.println("geslacht: " + geslacht);
System.out.println("Naam: " + naam);
}
//checken welke persoon ouder is
public boolean ouderDan(Persoon deAnder)
{
return geboorteInformatie.before(deAnder.geboorteInformatie);
//als de geboorte van de eerste persoon eerder was dan de ander dan zal er true uitkomen
}
} Last edited by Sereal_Killer : Dec 13th, 2008 at 4:33 pm. Reason: added code cause i forgot
![]() |
Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
- Creating first GUI Java Program (Java)
- java calendar SWING (Java)
- Help Java novice (Java)
- Java holiday system not working... (Java)
- How to get the current date in JAVA (JSP)
- Making A Java Compiler... In Java (Java)
- Trying to open explorer inside my java window (Java)
- Help with a Calendar!! (Java)
- help with sort using Calendar class getting null pointer exception (Java)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: popups without html
- Next Thread: Vertical Scrolling Gallery?
•
•
•
•
Views: 1322 | Replies: 1 | Currently Viewing: 1 (0 members and 1 guests)





Linear Mode