import java.util.Calendar;
public class Employee {
private Calendar doj;
public Employee(Calendar date) {
// TODO Auto-generated constructor stub
this.doj=date;
}
public Calendar getDoj()
{
return doj;
}
}
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class TestEmployeeSort {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
List<Employee> coll = getEmployees();
printList(coll);
}
public static List<Employee> getEmployees()
{
List<Employee> col = new ArrayList<Employee>();
col.add(new Employee(Calendar.getInstance()));
return col;
}
private static void printList(List<Employee> list) {
System.out.println("Date_Of_Joining");
for (int i = 0; i < list.size(); i++) {
Employee e = list.get(i);
System.out.println(e.getDoj());
}
}
}
The above codes produce the following output Date_Of_Joining java.util.GregorianCalendar[time=1291275522078,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2010,MONTH=11,WEEK_OF_YEAR=49,WEEK_OF_MONTH=1,DAY_OF_MONTH=2,DAY_OF_YEAR=336,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=1,HOUR_OF_DAY=13,MINUTE=8,SECOND=42,MILLISECOND=78,ZONE_OFFSET=19800000,DST_OFFSET=0]
I just need to print the date alone. How should i change the code?