import java.util.Calendar;
import java.util.Date;
public class Employee {
private Calendar doj;
public Employee(Calendar date) {
// TODO Auto-generated constructor stub
this.doj=date;
}
public Date getDoj()
{
Date cal=Calendar.getInstance().getTime();
return cal;
}
}
import java.text.SimpleDateFormat;
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>();
//SimpleDateFormat format=new SimpleDateFormat("DD/MM/YYY");
col.add(new Employee(null));
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());
}
}
}
這將打印當前日期。但我想設置日期如下,我已經使用日期。但我想這樣做使用日曆API日曆API設置許多日期
public static List<Employee> getEmployees()
{
List<Employee> col = new ArrayList<Employee>();
col.add(new Employee(5, "xyz","abc", new Date(1986, 6,12), new Date(1986, 6,12)));
return col;
}
我真的不明白你的問題。 – 2010-12-02 09:06:37