Merged 5.1.N (5.1.1) to HEAD (5.1)

114225 abozianu: Merged 5.0.N (5.0.3) to 5.1.N (5.1.1)
      114207 amorarasu: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3)
         114064 mrogers: Merged DEV to V4.2-BUG-FIX
            112453 : 	MNT-14685	ISO8601Converter throws ClassCastException


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123580 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-03-11 17:26:13 +00:00
parent 4162420146
commit 1f322c24f3

View File

@@ -18,12 +18,76 @@ public class ISO8601Converter implements Converter
{
if(clazz.equals(Date.class))
{
result = ISO8601DateFormat.parse((String) value);
if(value instanceof Date)
{
result = value;
}
else if(value instanceof String)
{
result = ISO8601DateFormat.parse((String) value);
}
else if (value instanceof Long)
{
Long longObj = (Long)value;
result = new Date(longObj);
}
else if (value instanceof java.sql.Date)
{
java.sql.Date valueX = (java.sql.Date)value;
return new Date(valueX.getTime());
}
else if (value instanceof java.sql.Time)
{
java.sql.Time valueX = (java.sql.Time)value;
return new Date(valueX.getTime());
}
if(value instanceof Calendar)
{
result = ((Calendar)value).getTime();
}
else
{
throw new IllegalArgumentException("Unsupported value type: " + value.getClass());
}
}
else if(clazz.equals(Calendar.class))
{
result = Calendar.getInstance();
((Calendar) result).setTime(ISO8601DateFormat.parse((String) value));
if(value instanceof Calendar)
{
result = value;
}
else if(value instanceof String)
{
result = Calendar.getInstance();
((Calendar) result).setTime(ISO8601DateFormat.parse((String) value));
}
else if(value instanceof Date)
{
result = Calendar.getInstance();
((Calendar) result).setTime((Date)value);
}
else if (value instanceof Long)
{
result = Calendar.getInstance();
Long longObj = (Long)value;
((Calendar) result).setTime(new Date(longObj));
}
else if (value instanceof java.sql.Date)
{
result = Calendar.getInstance();
java.sql.Date longObj = (java.sql.Date)value;
((Calendar) result).setTime(new Date(longObj.getTime()));
}
else if (value instanceof java.sql.Time)
{
result = Calendar.getInstance();
java.sql.Time longObj = (java.sql.Time)value;
((Calendar) result).setTime(new Date(longObj.getTime()));
}
else
{
throw new IllegalArgumentException("Unsupported value type: " + value.getClass());
}
}
else
{