Skip to content

Instantly share code, notes, and snippets.

@mkubala
Forked from ksiwonia/getDateField
Last active December 14, 2015 09:19
Show Gist options
  • Save mkubala/5064449 to your computer and use it in GitHub Desktop.
Save mkubala/5064449 to your computer and use it in GitHub Desktop.
public Date getDateField(final String fieldName) {
final Object fieldValue = getField(fieldName);
if (fieldValue == null) {
return null;
}
if (fieldValue instanceof Long) {
return new Date((Long) fieldValue);
}
if (fieldValue instanceof Date) {
Date fieldDateValue = (Date) fieldValue;
return new Date(fieldDateValue.getTime());
}
throw new IllegalArgumentException("Field " + fieldName + " in " + dataDefinition.getPluginIdentifier() + '.'
+ dataDefinition.getName() + " does not contain correct Date value");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment