If you can make them all implement an interface, that would certainly be the best option. However, reflection will also work, and your code was nearly there:
Object o = getFromSomeWhere.....;
Method m = o.getClass().getMethod("getDate");
Date date = (Date) m.invoke(o);
(There's a bunch of exceptions you'll need to handle, admittedly...)
For a full example:
import java.lang.reflect.*;
import java.util.*;
public class Test
{
public static void main(String[] args) throws Exception
{
Object o = new Test();
Method m = o.getClass().getMethod("getDate");
Date date = (Date) m.invoke(o);
System.out.println(date);
}
public Date getDate()
{
return new Date();
}
}