Example usage for java.util Date Date

List of usage examples for java.util Date Date

Introduction

In this page you can find the example usage for java.util Date Date.

Prototype

public Date() 

Source Link

Document

Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.

Usage

From source file:Main.java

public static void main(String args[]) {
    Date date = new Date();
    String DATE_FORMAT = "MM/dd/yyyy";
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
    System.out.println("Today is " + sdf.format(date));
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();
    String strDateFormat = "d";
    SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
    System.out.println("Current day in d format : " + sdf.format(date));

}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("MM");
    System.out.println("Current Month in MM format : " + sdf.format(date));
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("H");
    System.out.println("hour in H format : " + sdf.format(date));
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("kk");
    System.out.println("hour in kk format : " + sdf.format(date));
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("hh");
    System.out.println("hour in hh format : " + sdf.format(date));
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("KK");
    System.out.println("hour in KK format : " + sdf.format(date));
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("K");
    System.out.println("hour in K format : " + sdf.format(date));
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("zzzz");
    System.out.println("TimeZone in zzzz format : " + sdf.format(date));
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("M");
    System.out.println("Current Month in M format : " + sdf.format(date));
}