List of usage examples for java.util Date Date
public Date()
From source file:Main.java
public static void main(String[] argv) { System.out.println(getYear(new Date())); }
From source file:Main.java
public static void main(String[] argv) { System.out.println(getMonth(new Date())); }
From source file:Main.java
public static void main(String[] args) { System.out.println(addDays(new Date(), 100)); }
From source file:Main.java
public static void main(String[] args) throws Exception { Date date = new Date(); System.out.println("Format To times:"); System.out.println(date.getTime()); Timestamp ts = new Timestamp(date.getTime()); System.out.println(ts);/* www . jav a 2 s.c o m*/ }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy"); String strDate = sdf.format(date); System.out.println("formatted date in mm/dd/yy : " + strDate); sdf = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss"); strDate = sdf.format(date);//from w ww . java 2 s . c o m System.out.println("formatted date in mm-dd-yyyy hh:mm:ss : " + strDate); }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); String strDate = DateFormat.getDateInstance(DateFormat.DEFAULT).format(date); System.out.println(strDate);//from ww w.j a v a 2s . c o m strDate = DateFormat.getDateInstance(DateFormat.FULL).format(date); System.out.println(strDate); strDate = DateFormat.getDateInstance(DateFormat.LONG).format(date); System.out.println(strDate); strDate = DateFormat.getDateInstance(DateFormat.SHORT).format(date); System.out.println(strDate); }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); // Format date in a short format String today = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(date); System.out.println("Today " + today); // Format date in a medium format today = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(date); System.out.println("Today " + today); // Format date in a long format today = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(date); System.out.println("Today " + today); }
From source file:Main.java
public static void main(String[] args) { System.out.println(addSeconds(new Date(), 100)); }
From source file:Main.java
public static void main(String[] args) { System.out.println(round2Hour(new Date())); }
From source file:Main.java
public static void main(String[] args) { System.out.println(round2Day(new Date())); }