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[] argv) throws Exception {
    Object[] params = new Object[] { new Date(), new Date(0) };
    String msg = MessageFormat.format("{0,time,full} and UTC of 0 is {1,time,full}", params);

    System.out.println(msg);//from www .ja v a2  s .  c om
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Date today = new Date();

    String timestamp = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(today);
    System.out.println("timestamp = " + timestamp);

}

From source file:Touch.java

public static void main(String[] args) {
    String[] names = new File(".").list();

    Date current = new Date();

    for (int i = 0; i < names.length; i++) {
        File f = new File(names[i]);
        f.setLastModified(current.getTime());
    }//from   w ww  .j  av  a 2 s  .  c o m
}

From source file:PrintfExamples.java

public static void main(String[] args) {

    System.out.printf("The DATE is %tD\n", new Date());
    System.out.printf("The DATE is %tF\n", new Date());
    System.out.printf("The DATE is %tr\n", new Date());
    System.out.printf("The DATE is %tR\n", new Date());
    System.out.printf("The DATE is %tT\n", new Date());
}

From source file:Main.java

public static void main(String[] args) {
    File f = new File("C:/test.txt");
    long millisec = new Date().getTime();

    // set last modified time
    boolean bool = f.setLastModified(millisec);

    System.out.println("lastModified() succeeded?: " + bool);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Object[] params = new Object[] { new Date(), new Date(0) };
    String msg = MessageFormat.format("The time is {0} and UTC of 0 is {1}", params);

    msg = MessageFormat.format("The time is {0,time} and UTC of 0 is {1,time}", params);
    System.out.println(msg);//from  ww w .j a v a2 s  .c  om
}

From source file:Main.java

public static void main(String[] args) {
    System.out.println(asLocalDateIn(new Date(), ZoneId.systemDefault()));
}

From source file:Main.java

public static void main(String[] argv) {
    System.out.println(getMonthName(new Date()));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String s = DateFormat.getDateInstance().format(new Date());
    System.out.println(s);/*from   w  w  w .j a v  a  2  s  .com*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Date date = new Date();
    Format formatter = new SimpleDateFormat("hh:mm:ss a");
    String s = formatter.format(date);
    System.out.println(s);/*from  w w w . j  a v a  2s .c  o  m*/
}