What I\'m trying to do is pass a date into the Calendar so that it will format the date ready for use with another constructor. So that i can make use of it later using the func
Looks like too much work to me.
As a user, I'd rather pass a Date and make the contract clear. Provide a convenience method that converts String to Date:
public class Top {
public static final DateFormat DEFAULT_FORMAT;
static {
DEFAULT_FORMAT = new SimpleDateFormat("yyyy-MMM-dd");
DEFAULT_FORMAT.setLenient(false);
}
public static void main(String [] args) {
}
public static Date convert(String dateStr) throws ParseException {
return DEFAULT_FORMAT.parse(dateStr);
}
public static String convert(Date d) {
return DEFAULT_FORMAT.format(d);
}
}