public static String toJavaDateTimeFormat ( String strftime ) { if ( ! StringUtils . contains ( strftime , ' ' ) ) { return replaceL ( strftime ) ; } StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < strftime . length ( ) ; i ++ ) { char c = strftime . charAt ( i ) ; if ( c == ' ' ) { c = strftime . charAt ( ++ i ) ; boolean stripLeadingZero = false ; if ( c == ' ' ) { stripLeadingZero = true ; c = strftime . charAt ( ++ i ) ; } if ( stripLeadingZero ) { result . append ( CONVERSIONS [ c ] . substring ( 1 ) ) ; } else { result . append ( CONVERSIONS [ c ] ) ; } } else if ( Character . isLetter ( c ) ) { result . append ( "'" ) ; while ( Character . isLetter ( c ) ) { result . append ( c ) ; if ( ++ i < strftime . length ( ) ) { c = strftime . charAt ( i ) ; } else { c = 0 ; } } result . append ( "'" ) ; -- i ; // re-consume last char } else { result . append ( c ) ; } } return replaceL ( result . toString ( ) ) ; }
Parses a string in python strftime format returning the equivalent string in java date time format .