Created
January 16, 2015 14:51
-
-
Save raphi/2f00bc372f352f38b594 to your computer and use it in GitHub Desktop.
Compute age from an ElasticSearch document date
This file contains hidden or 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
def now = new Date() | |
def birthday = new Date(doc["birthdate"].value) | |
return Integer.parseInt(now.format("Y")) - Integer.parseInt(birthday.format("Y")) - (birthday > now ? 1 : 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment