@ Override public Object getConvertedValue ( FacesContext context , Object submittedValue ) throws ConverterException { if ( submittedValue == null ) { return null ; } String val = ( String ) submittedValue ; // If the Trimmed submitted value is empty, return null if ( val . trim ( ) . length ( ) == 0 ) { return null ; } Converter converter = this . getConverter ( ) ; // If the user supplied a converter, use it if ( converter != null ) { return converter . getAsObject ( context , this , val ) ; } // Else we use our own converter Locale sloc = BsfUtils . selectLocale ( context . getViewRoot ( ) . getLocale ( ) , this . getLocale ( ) , this ) ; String momentJSFormat = BsfUtils . selectMomentJSDateTimeFormat ( sloc , this . getFormat ( ) , this . isShowDate ( ) , this . isShowTime ( ) ) ; String javaFormat = LocaleUtils . momentToJavaFormat ( momentJSFormat ) ; Calendar cal = Calendar . getInstance ( sloc ) ; SimpleDateFormat format = new SimpleDateFormat ( javaFormat , sloc ) ; format . setTimeZone ( cal . getTimeZone ( ) ) ; try { cal . setTime ( format . parse ( val ) ) ; return cal . getTime ( ) ; } catch ( ParseException e ) { // FIRST STEP GONE: TRY THE AUTO-PARSER try { cal . setTime ( LocaleUtils . autoParseDateFormat ( val ) ) ; return cal . getTime ( ) ; } catch ( Exception pe ) { this . setValid ( false ) ; throw new ConverterException ( BsfUtils . getMessage ( "javax.faces.converter.DateTimeConverter.DATE" , val , javaFormat , BsfUtils . getLabel ( context , this ) ) ) ; } } }
Converts the date from the moment . js format to a java . util . Date .