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:DateFormatDemo.java

public static void main(String args[]) {
    Date date = new Date();
    DateFormat df = DateFormat.getTimeInstance(DateFormat.LONG);
    System.out.println("Long form: " + df.format(date));
}

From source file:Main.java

public static void main(String[] args) {

    // create a date
    Date date = new Date();

    // print the string representation
    System.out.println("String :  " + date.toString());
}

From source file:Main.java

public static void main(String[] a) {
    Date date = new Date();
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(date);/*from w w w.  ja  va  2 s .com*/
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();
    String strDate = DateFormat.getDateInstance(DateFormat.SHORT).format(date);

    System.out.println(strDate);/* ww  w . j a  va 2 s.c  o  m*/
}

From source file:DateFormatDemo.java

public static void main(String args[]) {
    Date date = new Date();
    DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
    System.out.println("Long form: " + df.format(date));

}

From source file:DateFormatDemo.java

public static void main(String args[]) {
    Date date = new Date();
    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
    System.out.println("Short form: " + df.format(date));

}

From source file:DateFormatDemo.java

public static void main(String args[]) {
    Date date = new Date();
    DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
    System.out.println("Short form: " + df.format(date));

}

From source file:Main.java

public static void main(String[] args) {
    Date dt = new Date();
    System.out.println("Date: " + dt);

    Instant in = dt.toInstant();/*from  ww  w .  j  a va2 s.c  o m*/
    System.out.println("Instant: " + in);

    Date dt2 = Date.from(in);
    System.out.println("Date: " + dt2);
}

From source file:Main.java

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

    String strDate = DateFormat.getDateInstance(DateFormat.MEDIUM).format(date);

    System.out.println(strDate);/*w w w.  ja  v a 2  s .  com*/
}

From source file:Main.java

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

    String strDate = DateFormat.getDateInstance(DateFormat.LONG).format(date);

    System.out.println(strDate);//from  w w  w  .j  a v a 2s.c o m
}