-
-
Save mkubala/5064449 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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