Created
May 24, 2020 19:21
-
-
Save kryvoboker/68774864161d47042999840dc461c54e to your computer and use it in GitHub Desktop.
HomeWork
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.Scanner; | |
/** | |
* | |
* @author kamaz | |
*/ | |
public class Main { | |
public static void main(String[] args) { | |
Date dateOne = new Date(); | |
Date dateTwo = new Date(); | |
Scanner sc = new Scanner(System.in); | |
String text = ""; | |
System.out.println("Input date dd:MM:yyyy"); | |
text = sc.nextLine(); | |
SimpleDateFormat sdf = new SimpleDateFormat("dd:MM:yyyy"); | |
SimpleDateFormat sdf1 = new SimpleDateFormat("MM:yyyy"); | |
try { | |
dateTwo = sdf.parse(text); | |
} catch (Exception e) { | |
System.out.println(e); | |
} | |
if (dateOne.compareTo(dateTwo) == 1 || dateOne.compareTo(dateTwo) == -1) { | |
System.out.println(sdf1.format(dateOne)); | |
System.out.println(sdf1.format(dateTwo)); | |
} else { | |
System.out.println(dateOne == dateTwo); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment