Skip to content

Instantly share code, notes, and snippets.

View gplgps's full-sized avatar

Gonçalo Silva gplgps

  • Ovar, Portugal
View GitHub Profile
gplgps /
Last active December 15, 2020 15:05
Portuguese Citizen Card number check for Java
public static boolean validateNumeroDocumentoCC(String numeroDocumento){
// C# Source:
int sum = 0;
boolean secondDigit = false;
if (numeroDocumento == null)
throw new IllegalArgumentException("Número de documento não pode ser null.");
if(numeroDocumento.length() != 12)
throw new IllegalArgumentException("Tamanho inválido para número de documento.");
for (int i = numeroDocumento.length()-1; i >= 0; --i){
int valor = getNumberFromChar(numeroDocumento.charAt(i));

Keybase proof

I hereby claim:

  • I am gplgps on github.
  • I am gplgps ( on keybase.
  • I have a public key ASC91-NFScJs9Nqlet3DVT8QwdG3TdHYRjWBKA0ZYIpGNQo

To claim this, I am signing this object: