public static String format(Date date,String ptrn){
  java.text.DateFormat format=new java.text.SimpleDateFormat(ptrn);
  return format.format(date);
}

public static String format ( Date date , String ptrn ) { java . text . DateFormat format = new java . text . SimpleDateFormat ( ptrn ) ; return format . format ( date ) ; }
formats passed date with specified pattern .
