Skip to content

Instantly share code, notes, and snippets.

@josinSbazin
Last active June 11, 2016 21:36
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 josinSbazin/972f5a9e6d3e906ccad5c47706115fdb to your computer and use it in GitHub Desktop.
Save josinSbazin/972f5a9e6d3e906ccad5c47706115fdb to your computer and use it in GitHub Desktop.
level08.lesson11.bonus01 - через Date
package com.javarush.test.level08.lesson11.bonus01;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/* Номер месяца
Программа вводит с клавиатуры имя месяца и выводит его номер на экран в виде: «May is 5 month».
Используйте коллекции.
*/
public class Solution {
public static void main(String[] args) throws IOException {
one:
while(true) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String month = reader.readLine();
month=month.substring(0,1).toUpperCase() + month.substring(1).toLowerCase();
try {
Date m = new Date(month + " 2 1999");
System.out.println(month + " is " + (int) (m.getMonth() + 1) + " month");
}
catch (IllegalArgumentException e) {
System.out.println("Невозможно определить месяц. Попробуйте еще раз: ");
continue one;
}
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment