Skip to content

Instantly share code, notes, and snippets.

@kevana
Created February 19, 2015 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevana/f51672d3f30a982ffe1c to your computer and use it in GitHub Desktop.
Save kevana/f51672d3f30a982ffe1c to your computer and use it in GitHub Desktop.
String extractExpirationYear(String cardExpiration) {
String year = cardExpiration == null || cardExpiration.length() != 6 ? "" : cardExpiration.substring(2, 6);
if ("".equals(year)) {
year = cardExpiration == null || cardExpiration.length() != 4 ? "" : "20" + cardExpiration.substring(2, 4);
}
return year;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment