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());
}
}
}
Les codes ci-dessus produisent la sortie suivante Date_Of_Joining java.util.GregorianCalendar [time = 1291275522078, areFieldsSet = true, areAllFieldsSet = true, clément = true, zone = sun.util. calendar.ZoneInfo [id = "Asie/Calcutta", décalage = 19800000, dstSavings = 0, useDaylight = faux, transitions = 6, lastRule = null], firstDayOfWeek = 1, minimalDaysInFirstWeek = 1, ERA = 1, YEAR = 2010, MOIS = 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, HEURE = 1, HOUR_OF_DAY = 13, MINUTE = 8, SECOND = 42, MILLISECOND = 78 , ZONE_OFFSET = 19800000, DST_OFFSET = 0]calendrier api pour afficher la date seule
J'ai juste besoin d'imprimer la date seule. Comment devrais-je changer le code?
Bon effort intellectuel, mais je pense - avoir ce sens lorsque l'heure de Joda et la nouvelle API java 9 existent sur le marché? Le troisième, date incompatible api? –