Hi,
I have a problem using the set method in the Calendar class.
When i try this:
everything is fine. The date gets set to whatever date it want to set it to.Code:public int changeDate (int newDate) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DATE, newDate);
return cal.get(Calendar.DATE); }
But now I implemented this in a class I made.
And I made a test class, with this testmethod in it.Code:public class Calender {
private Calendar cal;
public Calender() {
cal = Calendar.getInstance();
For some reason I can't get the date set to 20 in my testclass, it stays on 4.Code:
public void testGetDate() {
System.out.println("getDate");
Calender instance = new Calender();
instance.getCal().set(Calendar.DATE, 20);
int expResult = 20;
int result = instance.getDate();
assertEquals(expResult, result); }

