Hi,
I have a class with a java.util.Date object as part of it. I pass an object of this class to another which in turn sends it to another acouple of methods and finally sets the date field.
After the control returns to my original method, I am able to access the date value set by the other method. But when I pass this class object to another method, the date field has a value of null.
I overcame this problem by capturing the date in a local variable after it returns from the call to the first method. Then I set it back and it worked fine.
Pseudocode:
method1()
{
method2(myClass);
// Follwoing line prints date correctly as set by method2
System.out.print(myClass.getDate());
tempDate = myClass.getDate();
myClass.setDate(tempDate);
method3(myClass);
}
method2(myClassPassedByMethod1)
{
myClassPassedByMethod1.setDate(dateVariable);
}
method3(myClassObjectPassedByMethod1)
{
System.out.print(myClassObjectPassedByMethod1.getDate());
}
the pseudocode when implemeted works finw. But if you remove the reassignment in method1, the date is null in method3.
Any help would be very much appreciated and sorry for the long post. Thanks in advance.
Hope it helps. Let me know what happens.
With regards,
PGK
I have a class with a java.util.Date object as part of it. I pass an object of this class to another which in turn sends it to another acouple of methods and finally sets the date field.
After the control returns to my original method, I am able to access the date value set by the other method. But when I pass this class object to another method, the date field has a value of null.
I overcame this problem by capturing the date in a local variable after it returns from the call to the first method. Then I set it back and it worked fine.
Pseudocode:
method1()
{
method2(myClass);
// Follwoing line prints date correctly as set by method2
System.out.print(myClass.getDate());
tempDate = myClass.getDate();
myClass.setDate(tempDate);
method3(myClass);
}
method2(myClassPassedByMethod1)
{
myClassPassedByMethod1.setDate(dateVariable);
}
method3(myClassObjectPassedByMethod1)
{
System.out.print(myClassObjectPassedByMethod1.getDate());
}
the pseudocode when implemeted works finw. But if you remove the reassignment in method1, the date is null in method3.
Any help would be very much appreciated and sorry for the long post. Thanks in advance.
Hope it helps. Let me know what happens.
With regards,
PGK