java sort of time for which the object list

static void ListSort Private (List List) {
{// sorted by
the Collections.sort (List, new new Comparator () {
@Override
public int Compare (JzdtInfo O1, O2 JzdtInfo) {
the SimpleDateFormat the format the SimpleDateFormat new new = ( "the MM-dd-YYYY ");
the try {
// format.format (o1.getTime ()) represents a date transfer string type if the type is a string not converted to
a date DT1 = format.parse (format.format (o1.getTime ()));
a date = format.parse DT2 (format.format (o2.getTime ()));
// this is from large to small to be ordered from small to large, if comparison symbols can be converted
if (dt1.getTime () <dt2.getTime ( )) {
return. 1;
} the else IF (dt1.getTime ()> dt2.getTime ()) {
return -1;
} the else {
return 0;
}
} the catch (Exception E) {
e.printStackTrace ();
}
return 0;
}

		});
	}
}

Guess you like

Origin blog.csdn.net/soul17999/article/details/90313227