Example usage for java.util Date getTime

List of usage examples for java.util Date getTime

Introduction

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

Prototype

public long getTime() 

Source Link

Document

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.

Usage

From source file:DateDemo.java

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

    System.out.println(date);/* w w  w  .  j a v a2  s.co m*/

    long msec = date.getTime();
    System.out.println("Milliseconds since Jan. 1, 1970 GMT = " + msec);
}

From source file:Main.java

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

    System.out.println(date);/*from  ww w  .  j a  va2 s  . c om*/

    long msec = date.getTime();
    System.out.println("Milliseconds since Jan. 1, 1970 GMT=" + msec);
}

From source file:Main.java

public static void main(String[] args) {
    java.util.Date javaDate = new java.util.Date();
    long javaTime = javaDate.getTime();
    System.out.println("The Java Date is: " + javaDate.toString());

    java.sql.Date sqlDate = new java.sql.Date(javaTime);
    System.out.println("The SQL DATE is: " + sqlDate.toString());

    java.sql.Time sqlTime = new java.sql.Time(javaTime);
    System.out.println("The SQL TIME is: " + sqlTime.toString());

    java.sql.Timestamp sqlTimestamp = new java.sql.Timestamp(javaTime);
    System.out.println("The SQL TIMESTAMP is: " + sqlTimestamp.toString());
}

From source file:MainClass.java

public static void main(String[] args) {
    java.util.Date today = new java.util.Date();
    System.out.println(new java.sql.Date(today.getTime()));

}

From source file:MainClass.java

public static void main(String[] args) {

    java.util.Date today = new java.util.Date();
    System.out.println(new java.sql.Time(today.getTime()));

}

From source file:DateLabel.java

public static void main(String[] args) {
    java.util.Date today = new java.util.Date();
    System.out.println(new java.sql.Timestamp(today.getTime()));

}

From source file:Main.java

public static void main(String[] args) {
    java.util.Date javaDate = new java.util.Date();
    long javaTime = javaDate.getTime();
    System.out.println("The Java Date is:" + javaDate.toString());

    // SQL DATE/*  w  ww . j  a  v  a  2s.c o  m*/
    java.sql.Date sqlDate = new java.sql.Date(javaTime);
    System.out.println("The SQL DATE is: " + sqlDate.toString());

    // SQL TIME
    java.sql.Time sqlTime = new java.sql.Time(javaTime);
    System.out.println("The SQL TIME is: " + sqlTime.toString());

    // SQL TIMESTAMP
    java.sql.Timestamp sqlTimestamp = new java.sql.Timestamp(javaTime);
    System.out.println("The SQL TIMESTAMP is: " + sqlTimestamp.toString());
}

From source file:Main.java

public static void main(String[] args) throws java.lang.Exception {
    String[] StartTimes = { "10:00", "7:00" };
    String[] EndTimes = { "12:00", "14:56" };
    for (int i = 0; i < StartTimes.length; i++) {
        if (StartTimes != null && StartTimes.length > 0 && EndTimes != null && EndTimes.length > 0) {
            SimpleDateFormat format = new SimpleDateFormat("HH:mm");
            Date date1 = format.parse(StartTimes[i]);
            Date date2 = format.parse(EndTimes[i]);
            long millis = date2.getTime() - date1.getTime();

            String hourminute = String.format("%02d:%02d", TimeUnit.MILLISECONDS.toHours(millis),
                    TimeUnit.MILLISECONDS.toMinutes(millis)
                            - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)));
            System.out.println(hourminute);
        }//from   w ww  .j av a 2s  . c o m
    }
}

From source file:MainClass.java

public static void main(String[] args) {

    java.util.Date today = new java.util.Date();
    System.out.println(new java.sql.Timestamp(today.getTime()));

}

From source file:MainClass.java

public static void main(String[] args) throws ParseException {

    java.util.Date today = new java.util.Date();
    java.sql.Date date = new java.sql.Date(today.getTime());
    java.util.GregorianCalendar cal = new java.util.GregorianCalendar();
    cal.setTime(date);/*from www  . j  a  v a2  s. c  o  m*/
    System.out.println(cal.get(java.util.Calendar.DAY_OF_WEEK));

}