Skip to content

Instantly share code, notes, and snippets.

@mresetar
Created April 24, 2015 10: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 mresetar/28799c4fd518878f7158 to your computer and use it in GitHub Desktop.
Save mresetar/28799c4fd518878f7158 to your computer and use it in GitHub Desktop.
Prints current system date and time from Java
import java.util.*;
import java.text.*;
/**
* First compile class: c:\java\jdk1.7.0_71\bin\javac.exe DateDemo.java
* Secondly run it with: java -cp . DateDemo
*/
public class DateDemo {
public static void main(String args[]) {
final Date dNow = new Date( );
final SimpleDateFormat ft = new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz");
System.out.println("Current Date: " + ft.format(dNow));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment