-
-
Save mariiaKolokolova/8c38c3e3c9311d6d097d7820010c7890 to your computer and use it in GitHub Desktop.
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
package Maricka.Kolokolova; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.Date; | |
public class Main { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
Date dateTd = new Date(); | |
Date dateLm = new Date(); | |
String dtTd; | |
String dtLm; | |
SimpleDateFormat fr = new SimpleDateFormat("dd:MM:yyyy"); | |
dtTd = fr.format(dateTd); | |
Calendar cl = Calendar.getInstance(); | |
cl.add(Calendar.MONTH, -1); | |
dateLm = cl.getTime(); | |
dtLm = fr.format(dateLm); | |
System.out.println("Today is: " + dtTd); | |
System.out.println("Last month is: " + dtLm); | |
System.out.println("Milliseconds between: " + (dateTd.getTime() - dateLm.getTime())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment