5
My question is how to get a string and manipulate it. The user will inform dd/mm/yyyy in the form of String
. How do I make this catch? And then I need to make this date whole so that I can do the validations, for example if the informed day does not exceed 31.
For example, the user will inform the following String
: "21/03/2014", and I need to get this string and pass it as parameter to a method.
My code is this:
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
TAD01 verificacoes = new TAD01();
String data;
boolean resultado;
System.out.print("Informe a data: ");
data = input.nextLine();
resultado = verificacoes.converteData(data);
System.out.println(data);
}
Thank you in advance to all.
And if the last date is invalid you will have a java.text.Parseexception to deal with.
– deFreitas