diff --git a/processor/src/main/resources/org.mapstruct.ap.builtin.CalendarToXmlGregorianCalendar.ftl b/processor/src/main/resources/org.mapstruct.ap.builtin.CalendarToXmlGregorianCalendar.ftl index 289f63ab9..9af4c0165 100644 --- a/processor/src/main/resources/org.mapstruct.ap.builtin.CalendarToXmlGregorianCalendar.ftl +++ b/processor/src/main/resources/org.mapstruct.ap.builtin.CalendarToXmlGregorianCalendar.ftl @@ -19,6 +19,10 @@ --> private XMLGregorianCalendar ${name}( Calendar cal ) { + if ( cal == null ) { + return null; + } + try { GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis( cal.getTimeInMillis() ); @@ -27,4 +31,4 @@ private XMLGregorianCalendar ${name}( Calendar cal ) { catch ( DatatypeConfigurationException ex ) { throw new RuntimeException( ex ); } -} +} \ No newline at end of file diff --git a/processor/src/main/resources/org.mapstruct.ap.builtin.DateToXmlGregorianCalendar.ftl b/processor/src/main/resources/org.mapstruct.ap.builtin.DateToXmlGregorianCalendar.ftl index 160e4a96d..733a9c876 100644 --- a/processor/src/main/resources/org.mapstruct.ap.builtin.DateToXmlGregorianCalendar.ftl +++ b/processor/src/main/resources/org.mapstruct.ap.builtin.DateToXmlGregorianCalendar.ftl @@ -19,6 +19,10 @@ --> private XMLGregorianCalendar ${name}( Date date ) { + if ( date == null ) { + return null; + } + try { GregorianCalendar c = new GregorianCalendar(); c.setTime( date ); @@ -27,4 +31,4 @@ private XMLGregorianCalendar ${name}( Date date ) { catch ( DatatypeConfigurationException ex ) { throw new RuntimeException( ex ); } -} +} \ No newline at end of file diff --git a/processor/src/main/resources/org.mapstruct.ap.builtin.JaxbElemToValue.ftl b/processor/src/main/resources/org.mapstruct.ap.builtin.JaxbElemToValue.ftl index 9407b89d1..89ed1efb9 100644 --- a/processor/src/main/resources/org.mapstruct.ap.builtin.JaxbElemToValue.ftl +++ b/processor/src/main/resources/org.mapstruct.ap.builtin.JaxbElemToValue.ftl @@ -19,5 +19,9 @@ --> private T ${name}( JAXBElement element ) { + if ( element == null ) { + return null; + } + return element.isNil() ? null : element.getValue(); } \ No newline at end of file diff --git a/processor/src/main/resources/org.mapstruct.ap.builtin.StringToXmlGregorianCalendar.ftl b/processor/src/main/resources/org.mapstruct.ap.builtin.StringToXmlGregorianCalendar.ftl index b827a34e2..38c64afc8 100644 --- a/processor/src/main/resources/org.mapstruct.ap.builtin.StringToXmlGregorianCalendar.ftl +++ b/processor/src/main/resources/org.mapstruct.ap.builtin.StringToXmlGregorianCalendar.ftl @@ -19,6 +19,10 @@ --> private XMLGregorianCalendar ${name}( String date, String dateFormat ) { + if ( date == null ) { + return null; + } + try { DateFormat df = dateFormat != null ? new SimpleDateFormat( dateFormat ) : SimpleDateFormat.getInstance(); GregorianCalendar c = new GregorianCalendar(); @@ -31,4 +35,4 @@ private XMLGregorianCalendar ${name}( String date, String dateFormat ) { catch ( ParseException ex ) { throw new RuntimeException( ex ); } -} +} \ No newline at end of file diff --git a/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToCalendar.ftl b/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToCalendar.ftl index 366eaa117..a9d1bff06 100644 --- a/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToCalendar.ftl +++ b/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToCalendar.ftl @@ -19,6 +19,10 @@ --> private Calendar ${name}( XMLGregorianCalendar xcal ) { + if ( xcal == null ) { + return null; + } + Calendar cal = Calendar.getInstance(); cal.setTimeInMillis( xcal.toGregorianCalendar().getTimeInMillis() ); return cal; diff --git a/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToDate.ftl b/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToDate.ftl index 456f05b98..b9ae2b210 100644 --- a/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToDate.ftl +++ b/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToDate.ftl @@ -19,5 +19,9 @@ --> private static Date ${name}( XMLGregorianCalendar xcal ) { + if ( xcal == null ) { + return null; + } + return xcal.toGregorianCalendar().getTime(); -} +} \ No newline at end of file diff --git a/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToString.ftl b/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToString.ftl index efc76c076..2c70883cc 100644 --- a/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToString.ftl +++ b/processor/src/main/resources/org.mapstruct.ap.builtin.XmlGregorianCalendarToString.ftl @@ -19,11 +19,16 @@ --> private String ${name}( XMLGregorianCalendar xcal, String dateFormat ) { + if ( xcal == null ) { + return null; + } + if (dateFormat == null ) { return xcal.toString(); - } else { + } + else { Date d = xcal.toGregorianCalendar().getTime(); SimpleDateFormat sdf = new SimpleDateFormat( dateFormat ); return sdf.format( d ); } -} +} \ No newline at end of file