protected String convertDateFormat(String pattern){
  boolean inside=false;
  boolean mark=false;
  boolean modifiedCommand=false;
  StringBuilder buf=new StringBuilder();
  for (int i=0; i < pattern.length(); i++) {
    char c=pattern.charAt(i);
    if (c == '%' && !mark) {
      mark=true;
    }
 else {
      if (mark) {
        if (modifiedCommand) {
          modifiedCommand=false;
          mark=false;
        }
 else {
          inside=translateCommand(buf,pattern,i,inside);
          if (c == 'O' || c == 'E') {
            modifiedCommand=true;
          }
 else {
            mark=false;
          }
        }
      }
 else {
        if (!inside && c != ' ') {
          buf.append("'");
          inside=true;
        }
        buf.append(c);
      }
    }
  }
  if (buf.length() > 0) {
    char lastChar=buf.charAt(buf.length() - 1);
    if (lastChar != '\'' && inside) {
      buf.append('\'');
    }
  }
  return buf.toString();
}

protected String convertDateFormat ( String pattern ) { boolean inside = false ; boolean mark = false ; boolean modifiedCommand = false ; StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < pattern . length ( ) ; i ++ ) { char c = pattern . charAt ( i ) ; if ( c == '%' && ! mark ) { mark = true ; } else { if ( mark ) { if ( modifiedCommand ) { modifiedCommand = false ; mark = false ; } else { inside = translateCommand ( buf , pattern , i , inside ) ; if ( c == 'O' || c == 'E' ) { modifiedCommand = true ; } else { mark = false ; } } } else { if ( ! inside && c != ' ' ) { buf . append ( "'" ) ; inside = true ; } buf . append ( c ) ; } } } if ( buf . length ( ) > 0 ) { char lastChar = buf . charAt ( buf . length ( ) - 1 ) ; if ( lastChar != '\'' && inside ) { buf . append ( '\'' ) ; } } return buf . toString ( ) ; }
search the provided pattern and get the c standard date / time formatting rules and convert them to the java equivalent .
