private static CSLDate merge ( CSLDate d1 , CSLDate d2 ) { if ( d1 == null ) { return d2 ; } else if ( d2 == null ) { return d1 ; } CSLDateBuilder builder = new CSLDateBuilder ( ) ; //handle date parts builder . dateParts ( d1 . getDateParts ( ) [ 0 ] , d2 . getDateParts ( ) [ d2 . getDateParts ( ) . length - 1 ] ) ; //handle circa if ( d1 . getCirca ( ) != null ) { builder . circa ( d1 . getCirca ( ) ) ; } if ( d2 . getCirca ( ) != null && ( d1 . getCirca ( ) == null || d2 . getCirca ( ) . booleanValue ( ) ) ) { builder . circa ( d2 . getCirca ( ) ) ; } //handle literal strings if ( d1 . getLiteral ( ) != null ) { builder . literal ( d1 . getLiteral ( ) ) ; } if ( d2 . getLiteral ( ) != null ) { if ( d1 . getLiteral ( ) != null ) { builder . literal ( d1 . getLiteral ( ) + "-" + d2 . getLiteral ( ) ) ; } else { builder . literal ( d2 . getLiteral ( ) ) ; } } //handle seasons if ( d1 . getSeason ( ) != null ) { builder . season ( d1 . getSeason ( ) ) ; } if ( d2 . getSeason ( ) != null ) { if ( d1 . getSeason ( ) != null ) { builder . season ( d1 . getSeason ( ) + "-" + d2 . getSeason ( ) ) ; } else { builder . season ( d2 . getSeason ( ) ) ; } } //handle raw strings if ( d1 . getRaw ( ) != null ) { builder . raw ( d1 . getRaw ( ) ) ; } if ( d2 . getRaw ( ) != null ) { if ( d1 . getRaw ( ) != null ) { builder . raw ( d1 . getRaw ( ) + "-" + d2 . getRaw ( ) ) ; } else { builder . raw ( d2 . getRaw ( ) ) ; } } return builder . build ( ) ; }
Merges two dates