Skip to content

Instantly share code, notes, and snippets.

@userddssilva
Created April 9, 2021 19:23
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 userddssilva/6815c027f138b24479dce65166e0c3be to your computer and use it in GitHub Desktop.
Save userddssilva/6815c027f138b24479dce65166e0c3be to your computer and use it in GitHub Desktop.
// Configure o SimpleDateFormat no onCreate ou onCreateView
String pattern = "dd/MM/yyyy";
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
sdf.setLenient(false);
// Durante a confirmacao de cadastro, faça a validacao
String data = NascimentoUsu.getText().toString();
try {
Date date = sdf.parse(data);
// Data formatada corretamente
} catch (ParseException e) {
// Erro de parsing!!
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment