Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void setDatumRegistracije(String datumRegistracije) throws InvalidDatumException {
- String date = datumRegistracije;
- int duzina = date.length();
- String dan = date.substring(0, 2);
- String mesec = date.substring(3, 5);
- String godina = date.substring(6, duzina);
- char[] input = date.toCharArray();
- if((input[0] < '0' || input[0] > '9') ||
- (input[1] < '0' || input[1] > '9') ||
- (input[2] != '/') ||
- (input[3] < '0' || input[3] > '9') ||
- (input[4] < '0' || input[4] > '9') ||
- (input[5] != '/') ||
- (input[6] < '0' || input[6] > '9') ||
- (input[7] < '0' || input[7] > '9') ||
- (input[8] < '0' || input[8] > '9') ||
- (input[9] < '0' || input[9] > '9') ||
- (duzina != 10)
- )
- throw new InvalidDatumException("Unesite datum u trazenom formatu!");
- else {
- int d = Integer.parseInt(dan);
- int m = Integer.parseInt(mesec);
- int y = Integer.parseInt(godina);
- this.datumRegistracije.set(y, m-1, d);
- }
- }
Add Comment
Please, Sign In to add comment