Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. public class DataFormat {
  2. public static void main(String[] args) {
  3. Scanner input = new Scanner(System.in);
  4.  
  5. System.out.println("input year(number): ");
  6. int year = input.nextInt();
  7.  
  8. System.out.println("Please input month(number): ");
  9. int month = input.nextInt();
  10.  
  11. System.out.println("Please input day(number): ");
  12. int day = input.nextInt();
  13.  
  14. input.nextLine();
  15. System.out.println("Please select a format (b/l/m): ");
  16. String format = input.nextLine();
  17.  
  18.  
  19. if (format.equals("b")){
  20. if (month >=10){
  21. System.out.println(year + "/" + month + "/" + day);
  22. }
  23. else{
  24. System.out.println(year + "/0" + month + "/" + day);
  25. }
  26.  
  27. }
  28. else if(format.equals("m")){
  29. if (month >=10){
  30. System.out.println(month + "/" + day + "/" + year); }
  31. else{
  32. System.out.println("0"+month + "/" + day + "/" + year);
  33. }
  34. }
  35.  
  36. else if(format.equals("l")){
  37. if (month >=10){
  38. System.out.println(day + "/" + month + "/" + year); }
  39. else{
  40. System.out.println(day + "/" + "0"+ month + "/" + year); }
  41. }
  42.  
  43.  
  44.  
  45.  
  46. input.close();
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement