public static String convertToGYear(Object jsObject) throws AxisFault {
try {
// If the user returned a valid GYear a s a String we use the converterUtil to
// validate it and return it back.
if (jsObject instanceof String) {
Year year = ConverterUtil.convertToGYear((String)jsObject);
return ConverterUtil.convertToString(year);
}
Date date = (Date) Context.jsToJava(jsObject, Date.class);
Calendar calendar = Calendar.getInstance();
calendar.clear();
calendar.setTime(date);
Year year = new Year(calendar.get(Calendar.YEAR));
return ConverterUtil.convertToString(year);
} catch (EvaluatorException e) {
throw new AxisFault("Unable to convert the return value to year");
} catch (NumberFormatException e) {
throw new AxisFault("Unable to convert the return value to day");