public static String now(String dateFormat){
  Calendar cal=Calendar.getInstance();
  SimpleDateFormat sdf=new SimpleDateFormat(dateFormat);
  return sdf.format(cal.getTime());
}

public static String now ( String dateFormat ) { Calendar cal = Calendar . getInstance ( ) ; SimpleDateFormat sdf = new SimpleDateFormat ( dateFormat ) ; return sdf . format ( cal . getTime ( ) ) ; }
returns current date time in given dateformat
