Skip to content

Instantly share code, notes, and snippets.

@thauansrx
Last active September 27, 2019 23:14
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 thauansrx/c6bce6bcf86e3a888691f0caf1f7566f to your computer and use it in GitHub Desktop.
Save thauansrx/c6bce6bcf86e3a888691f0caf1f7566f to your computer and use it in GitHub Desktop.
horario_atual
class eraUnix {
public static void main(String[] args) {
long totalMilisegundos = System.currentTimeMillis();
//*****************Segundos atual*****************
long totalSegundos = totalMilisegundos / 1000;
long segundoAtual = totalSegundos % 60;
//*****************Minutos atual*****************
long totalMinutos = totalSegundos /60;
long minutoAtual = totalMinutos % 60;
//*****************Horas atual*****************
long totalHoras = totalMinutos / 60;
long horaAtual = totalHoras % 24;
//*****************Horario BRASIL*****************
long horaBrasil = horaAtual - 3;
System.out.println("\n"+horaBrasil+":"+minutoAtual+":"+segundoAtual);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment