Source:
<code>private static String createDateSortStringForAffiliations(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate startDate, org.orcid.jaxb.model.v3.dev1.common.FuzzyDate endDate, org.orcid.jaxb.model.v3.dev1.common.CreatedDate createdDate) { String dateSortString = ""; if(startDate == null && endDate == null) { XMLGregorianCalendar date = createdDate.getValue(); dateSortString = "Z-" + date.getYear() + "-" + date.getMonth() + "-" + date.getDay(); } else { if(endDate == null) { dateSortString = "Y-"; dateSortString += startDate.getYear() == null ? "NaN" : startDate.getYear().getValue(); if (!PojoUtil.isEmpty(startDate.getMonth())) dateSortString += "-" + startDate.getMonth().getValue(); if (!PojoUtil.isEmpty(startDate.getDay())) dateSortString += "-" + startDate.getDay().getValue(); } else { dateSortString = "X-"; dateSortString += endDate.getYear() == null ? "NaN" : endDate.getYear().getValue(); <START> if (!PojoUtil.isEmpty(endDate.getMonth())) <END> dateSortString += "-" + endDate.getMonth().getValue(); if (!PojoUtil.isEmpty(endDate.getDay())) dateSortString += "-" + endDate.getDay().getValue(); if(startDate != null) { dateSortString += startDate.getYear() == null ? "-NaN" : "-" + startDate.getYear().getValue(); if (!PojoUtil.isEmpty(startDate.getMonth())) dateSortString += "-" + startDate.getMonth().getValue(); if (!PojoUtil.isEmpty(startDate.getDay())) dateSortString += "-" + startDate.getDay().getValue(); } } } return dateSortString; }</code><technical_language>00 is is for month day, sort string is length</technical_language>

Target:
private static String createDateSortStringForAffiliations(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate startDate, org.orcid.jaxb.model.v3.dev1.common.FuzzyDate endDate, org.orcid.jaxb.model.v3.dev1.common.CreatedDate createdDate) { String dateSortString = ""; if (startDate == null && endDate == null) { XMLGregorianCalendar date = createdDate.getValue(); dateSortString = "Z-" + date.getYear() + "-" + date.getMonth() + "-" + date.getDay(); } else { if (endDate == null) { dateSortString = "Y-"; dateSortString += startDate.getYear() == null ? "NaN" : startDate.getYear().getValue(); if (!PojoUtil.isEmpty(startDate.getMonth())) { dateSortString += "-" + startDate.getMonth().getValue(); } else { dateSortString += "-00"; } if (!PojoUtil.isEmpty(startDate.getDay())) { dateSortString += "-" + startDate.getDay().getValue(); } else { dateSortString += "-00"; } } else { dateSortString = "X-"; dateSortString += endDate.getYear() == null ? "NaN" : endDate.getYear().getValue(); if (!PojoUtil.isEmpty(endDate.getMonth())) { dateSortString += "-" + endDate.getMonth().getValue(); } else { dateSortString += "-00"; } if (!PojoUtil.isEmpty(endDate.getDay())) { dateSortString += "-" + endDate.getDay().getValue(); } else { dateSortString += "-00"; } if (startDate != null) { dateSortString += startDate.getYear() == null ? "-NaN" : "-" + startDate.getYear().getValue(); if (!PojoUtil.isEmpty(startDate.getMonth())) { dateSortString += "-" + startDate.getMonth().getValue(); } else { dateSortString += "-00"; } if (!PojoUtil.isEmpty(startDate.getDay())) { dateSortString += "-" + startDate.getDay().getValue(); } else { dateSortString += "-00"; } } } } return dateSortString; }