}
/**
- * Should mimic the List<E> add(int index, T value) method
+ * Should mimic the List<E> add(int index, E value) method
* @param index [description]
* @param value [description]
* @return [description]
import java.util.LinkedList;
import java.lang.annotation.Annotation;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.text.ParseException;
class Main {
public static void main(String[] args) {
//FIXME: one can create a smart way of building this list
LinkedList<Class<?>> packageClasses = new LinkedList<Class<?>>();
+ packageClasses.add(Cercle.class);
packageClasses.add(Entiers.class);
packageClasses.add(Forme.class);
packageClasses.add(Image.class);
packageClasses.add(Segment.class);
packageClasses.add(Structure.class);
+ System.out.println("Class list created after 2009:");
for (Class<?> cl : packageClasses) {
ClassPreamble classPreamble = cl.getAnnotation(ClassPreamble.class);
if (classPreamble == null) {
System.out.println("No annotation for " + cl.getName());
continue;
}
- System.out.println(cl.getName() + " class annotation date = " + classPreamble.date());
+ try {
+ SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy");
+ Date date = sdf.parse(classPreamble.date());
+ Integer classYear = date.getYear() + 1900;
+ if (classYear >= 2009) {
+ System.out.println(" " + cl.getName() + " created year " + classYear + ".");
+ }
+ }
+ catch (ParseException e) {
+
+ }
}
}
}