Skip to content

Instantly share code, notes, and snippets.

@zivce
Created April 17, 2021 16:47
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 zivce/7c5f70cc9279d02a0ab89a3b0d74b453 to your computer and use it in GitHub Desktop.
Save zivce/7c5f70cc9279d02a0ab89a3b0d74b453 to your computer and use it in GitHub Desktop.
private OptionalInt readExpirationAsInt(Milk milk)
{
String expiration = milk.getExpiration();
try {
return Optional.of(Integer.parseInt(expiration));
}
catch(NumberFormatException e) {
return OptionalInt.empty();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment