public int compare(Object o1, Object o2) { InfoPublication infoPublication1 = (InfoPublication) o1; InfoPublication infoPublication2 = (InfoPublication) o2; int year1,year2;    year1 = Integer.parseInt(infoPublication1.getYear()); year2 = Integer.parseInt(infoPublication2.getYear());  if (year1 < year2) return 1; if (year1 == year2) return 0; return -1;  }
public int compare(Object o1, Object o2) { InfoPublication infoPublication1 = (InfoPublication) o1; InfoPublication infoPublication2 = (InfoPublication) o2; int year1, year2;  if (infoPublication1.getYear() != null && infoPublication2.getYear() != null && StringUtils.isNumeric(infoPublication1.getYear()) && StringUtils.isNumeric(infoPublication2.getYear())) { year1 = Integer.parseInt(infoPublication1.getYear()); year2 = Integer.parseInt(infoPublication2.getYear());  if (year1 < year2) return 1; if (year1 == year2) return 0; return -1; } return 0; }
	public ActionForward execute(			ActionMapping mapping,			ActionForm actionForm,			HttpServletRequest request,			HttpServletResponse response)	throws Exception	{	    		IUserView userView = SessionUtils.getUserView(request);				Object[] args = { userView.getUtilizador()};				SiteView siteView =			(SiteView) ServiceUtils.executeService(userView, "ReadAuthorPublications", args);		InfoSitePublications infoSitePublications = (InfoSitePublications)siteView.getComponent();				List listaPub = infoSitePublications.getInfoPublications();				/** this class is a mere comparator to sort publications */		class PublicationComparator implements Comparator {		    public int compare(Object o1, Object o2) {		        InfoPublication infoPublication1 = (InfoPublication) o1;		        InfoPublication infoPublication2 = (InfoPublication) o2;		        int year1,year2;		        		        //date sorting rules for publications//		        try {		            year1 = Integer.parseInt(infoPublication1.getYear());		            year2 = Integer.parseInt(infoPublication2.getYear());		            		            if (year1 < year2)		                return 1;		            if (year1 == year2)		                return 0;                    return -1;/*		        } catch (NumberFormatException nfe) {         throw nfe;      }*/		    }		}				Collections.sort(listaPub,new PublicationComparator());		infoSitePublications.setInfoPublications(listaPub);		request.setAttribute("infoSitePublications",infoSitePublications);	    		String msg = (String) request.getAttribute("msg");		if (msg != null){		    ActionMessages messages = new ActionMessages();			messages.add("message1", new ActionMessage(msg));			saveMessages(request,messages);		}		//		ActionErrors errors = new ActionErrors();//		errors.add("error1", new ActionError("message.publications.managementDeleted"));//		saveErrors(request,errors);				return mapping.findForward("show-publications");	}