List of usage examples for java.util Date Date
public Date()
From source file:DateAdd.java
public static void main(String[] av) { //+//from w ww. j av a 2s . co m /** Today's date */ Date now = new Date(); long t = now.getTime(); t -= 700 * 24 * 60 * 60 * 1000; Date then = new Date(t); System.out.println("Seven hundred days ago was " + then); //- }
From source file:MainClass.java
public static void main(String args[]) { Date date = new Date(); SimpleDateFormat sdf;// ww w. j a va2 s . c om sdf = new SimpleDateFormat("hh:mm:ss"); System.out.println(sdf.format(date)); sdf = new SimpleDateFormat("dd MMM yyyy hh:mm:ss zzz"); System.out.println(sdf.format(date)); sdf = new SimpleDateFormat("E MMM dd yyyy"); System.out.println(sdf.format(date)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DateFormat dateFormat = DateFormat.getInstance(); String s = dateFormat.format(new Date()); System.out.println(s);// w w w . j av a 2 s .co m }
From source file:Main.java
public static void main(String[] args) { SimpleDateFormat simpleFormatter = new SimpleDateFormat("dd/MM/yyyy"); Date today = new Date(); String formattedDate = simpleFormatter.format(today); System.out.println("Today is (dd/MM/yyyy): " + formattedDate); simpleFormatter.applyPattern("MMMM dd, yyyy"); formattedDate = simpleFormatter.format(today); System.out.println("Today is (MMMM dd, yyyy): " + formattedDate); }
From source file:Main.java
public static void main(String[] args) { // Date to Instant Instant timestamp = new Date().toInstant(); // convert Instant to LocalDateTime or other similar classes LocalDateTime date = LocalDateTime.ofInstant(timestamp, ZoneId.of(ZoneId.SHORT_IDS.get("PST"))); System.out.println("Date = " + date); }
From source file:array05.java
public static void main(String[] args) { SimpleDateFormat sf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); System.out.println(sf.format(new Date())); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DateFormat dateFormat = DateFormat.getDateInstance(); String s = dateFormat.format(new Date()); System.out.println(s);/*w ww . j ava 2 s .c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { DateFormat dateFormat = DateFormat.getTimeInstance(); String s = dateFormat.format(new Date()); System.out.println(s);//from w ww . ja v a2 s. co m }
From source file:Main.java
public static void main(String[] args) { System.out.println(fromDate(new Date())); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DateFormat dateFormat = DateFormat.getDateTimeInstance(); String s = dateFormat.format(new Date()); System.out.println(dateFormat.isLenient()); }