List of usage examples for java.text DateFormat format
public final String format(Date date)
From source file:Main.java
public static void main(String[] argv) throws Exception { DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG, Locale.getDefault()); String s = dateFormat.format(new Date()); System.out.println(s);/* ww w.j a v a 2s.c om*/ }
From source file:DateFormatBest.java
public static void main(String[] args) { Date today = new Date(); DateFormat df = DateFormat.getInstance(); System.out.println(df.format(today)); DateFormat df_fr = DateFormat.getDateInstance(DateFormat.FULL, Locale.FRENCH); System.out.println(df_fr.format(today)); }
From source file:CalendarManipulation.java
public static void main(String s[]) { Calendar cal = Calendar.getInstance(); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM); System.out.println(df.format(cal.getTime())); cal.add(Calendar.DATE, 8);/*from w w w . java2 s.co m*/ System.out.println(df.format(cal.getTime())); }
From source file:CalendarManipulation.java
public static void main(String s[]) { Calendar cal = Calendar.getInstance(); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM); System.out.println(df.format(cal.getTime())); cal.add(Calendar.HOUR, -4);// www . ja v a 2 s .co m System.out.println(df.format(cal.getTime())); }
From source file:CalendarManipulation.java
public static void main(String s[]) { Calendar cal = Calendar.getInstance(); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM); System.out.println(df.format(cal.getTime())); cal.add(Calendar.AM_PM, 1);/*from w ww . ja v a2 s. co m*/ System.out.println(df.format(cal.getTime())); }
From source file:MainClass.java
public static void main(String[] args) { Date today = new Date(); DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.US); String formatted = fmt.format(today); System.out.println(formatted); }
From source file:Main.java
public static void main(String[] args) { Date today = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(today);/*from www . j a va2 s . com*/ calendar.add(Calendar.MONTH, 1); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.DATE, -1); Date lastDayOfMonth = calendar.getTime(); DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); System.out.println("Today : " + sdf.format(today)); System.out.println("Last Day of Month: " + sdf.format(lastDayOfMonth)); }
From source file:ShowDate.java
public static void main(String[] args) { DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.CANADA_FRENCH); System.out.println(df.format(new Date())); }
From source file:JapaneseCalendar.java
public static void main(String[] args) { Locale japanese = new Locale("ja", "JP", "JP"); Calendar cal = Calendar.getInstance(japanese); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, japanese); String str = df.format(cal.getTime()); JOptionPane.showMessageDialog(null, str); }
From source file:Main.java
public static void main(String[] args) { String[] newMonths = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; String[] newShortMonths = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" }; String[] newWeekdays = { "", "Monday", "Tuesday", "Webnesday", "Thursday", "Friday", "Saturaday", "Sunday" }; String[] shortWeekdays = { "", "monday", "tuesday", "webnesday", "thursday", "friday", "saturaday", "sunday" }; DateFormatSymbols symbols = new DateFormatSymbols(); symbols.setMonths(newMonths);//ww w . j av a 2 s . com symbols.setShortMonths(newShortMonths); symbols.setWeekdays(newWeekdays); symbols.setShortWeekdays(shortWeekdays); DateFormat format = new SimpleDateFormat("dd MMMM yyyy", symbols); System.out.println(format.format(new Date())); format = new SimpleDateFormat("dd MMM yyyy", symbols); System.out.println(format.format(new Date())); format = new SimpleDateFormat("EEEE, dd MMM yyyy", symbols); System.out.println(format.format(new Date())); format = new SimpleDateFormat("E, dd MMM yyyy", symbols); System.out.println(format.format(new Date())); }