Skip to content

Instantly share code, notes, and snippets.

@mariiaKolokolova
Created May 22, 2020 15:30
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 mariiaKolokolova/8c38c3e3c9311d6d097d7820010c7890 to your computer and use it in GitHub Desktop.
Save mariiaKolokolova/8c38c3e3c9311d6d097d7820010c7890 to your computer and use it in GitHub Desktop.
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