List of usage examples for java.text SimpleDateFormat format
private StringBuffer format(Date date, StringBuffer toAppendTo, FieldDelegate delegate)
From source file:Main.java
public static void main(String[] argv) throws Exception { SimpleDateFormat formatter = new SimpleDateFormat(); StringBuffer sb = new StringBuffer(); formatter.format(new Date(), sb, new FieldPosition(DateFormat.DATE_FIELD)); System.out.println(sb);//from w w w.j a va2 s .c om }
From source file:Main.java
public static void main(String args[]) { int days = 1; int month = 1; int year = 2001; SimpleDateFormat sdf = new SimpleDateFormat("E dd-MM-yyyy G"); StringBuffer buf = new StringBuffer(); Calendar cal = new GregorianCalendar(); cal.set(year, month - 1, days);/*from w ww . j a va 2 s.c om*/ sdf.format(cal.getTime(), buf, new FieldPosition(10)); System.out.println(buf.toString()); }