Skip to content

Instantly share code, notes, and snippets.

@wellingtonpgp
Last active March 1, 2020 23:21
Show Gist options
  • Save wellingtonpgp/ab101fb75a9bcc78a9747057e6c788fd to your computer and use it in GitHub Desktop.
Save wellingtonpgp/ab101fb75a9bcc78a9747057e6c788fd to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
public class Main {
public static void main(String[] args) {
List<Integer> lista = new ArrayList<>();
lista.addAll(Arrays.asList(2000010, 2000013));
Integer valor = Collections.max(lista);
valor++;
String novoValor = valor.toString();
String ano = novoValor.substring(0, 2);
String numero = novoValor.substring(2, 7);
System.out.println(numero + "/" + ano);
Integer maior = lista.stream().mapToInt(v -> v).max().orElseThrow(NoSuchElementException::new);
maior++;
String novoValor2 = maior.toString();
String ano2 = novoValor2.substring(0, 2);
String numero2 = novoValor2.substring(2, 7);
System.out.println(numero2 + "/" + ano2);
// 00014/20
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment