List of usage examples for java.util Date Date
public Date()
From source file:Main.java
public static void main(String[] argv) throws Exception { String s = DateFormat.getDateInstance(DateFormat.DEFAULT).format(new Date()); System.out.println(s);//from w w w .j a v a2s . co m }
From source file:Main.java
public static void main(String args[]) { Date date = new Date(); Format formatter = new SimpleDateFormat("dd/MM/yyyy"); String s = formatter.format(date); System.out.println(s);/*w w w .j a v a 2s. c om*/ date = new Date(); String df = DateFormat.getDateInstance().format(date); System.out.println(df); }
From source file:Main.java
public static void main(String[] args) { Date today = new Date(); // Print date in the default locale format Locale defaultLocale = Locale.getDefault(); printLocaleDetails(defaultLocale);/*from w w w . j av a 2s. co m*/ printDate(defaultLocale, today); // Print date in French format printLocaleDetails(Locale.FRANCE); printDate(Locale.FRANCE, today); // Print date in German format. We could also use Locale.GERMANY // instead of new Locale ("de", "DE"). Locale germanLocale = new Locale("de", "DE"); printLocaleDetails(germanLocale); printDate(germanLocale, today); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Date date = new Date(); System.out.printf("The date is %tc\n", date); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Date date = new Date(); System.out.printf("The DATE is %Tc\n", date); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Date date = new Date(); System.out.printf("The date is %s\n", date); }
From source file:Main.java
public static void main(String[] args) { Object obj1 = "Object"; Object obj2 = 2;/*from w w w. j a va 2s . c o m*/ Date date = new Date(); try { PrintWriter pw = new PrintWriter(System.out); // print object pw.print(obj1); // print another object pw.print(obj2); // print a date (it is an object) pw.print(date); pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:KVMCalendar.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); Date date = new Date(); cal.setTime(date);//w ww. j ava 2 s. c om int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); System.out.println("Day is " + day + ", month is " + month); final long MILLIS_PER_DAY = 24 * 60 * 60 * 1000L; long offset = date.getTime(); offset += 20 * MILLIS_PER_DAY; date.setTime(offset); cal.setTime(date); month = cal.get(Calendar.MONTH); day = cal.get(Calendar.DAY_OF_MONTH); System.out.println("In 20 days time, day will " + day + ", month will be " + month); System.out.println(cal); }
From source file:Main.java
public static void main(String[] args) { Object obj1 = "Object"; Object obj2 = 2;/* w w w . j av a2s . c om*/ Date date = new Date(); try { PrintWriter pw = new PrintWriter(System.out); // print object pw.println(obj1); // print another object pw.println(obj2); // print a date (it is an object) pw.print(date); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss"); Date now = new Date(); String strTime = sdfTime.format(now); System.out.println("Time: " + strTime); }