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

public static void main(String args[]) {

    Date date = new Date();

    long msec = date.getTime();

    msec += 100 * 24 * 60 * 60 * 1000L;//from   w ww  .  j  av  a 2s  . c  o  m

    date.setTime(msec);

    System.out.println(date);
}

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("Today is {0} and UTC of 0 is {1}", params);

    System.out.println(msg);/*from w w w.  j  a v  a 2s .co m*/
}

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("Today is {0,date} and UTC of 0 is {1,date}", params);

    System.out.println(msg);/*from  w  w w. ja  va 2 s. co m*/
}

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("Today is {0,date,short} and UTC of 0 is {1,date,short}", params);

    System.out.println(msg);/*  w w  w.j  ava 2  s  .  c  o  m*/
}

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,medium} and UTC of 0 is {1,time,medium}", params);

    System.out.println(msg);/*from  w ww .  jav  a2s.  c  o m*/
}

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("Today is {0,date,long} and UTC of 0 is {1,date,long}", params);

    System.out.println(msg);// ww  w.  j av  a 2  s .com
}

From source file:Main.java

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

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

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("Today is {0,date,medium} and UTC of 0 is {1,date,medium}", params);

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

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,HH-mm-ss} and UTC of 0 is {1,time,HH-mm-ss}", params);

    System.out.println(msg);//from   www. j  av  a2s.c  o m
}

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,long} and UTC of 0 is {1,time,long}", params);

    System.out.println(msg);/*from   w  w w .  j  a  va 2 s. com*/
}