private Locale toLocale(String str){
  if (str == null)   return null;
  String[] split=str.split("_");
  if (split.length == 0)   return new Locale("");
 else   if (split.length == 1)   return new Locale(split[0]);
 else   if (split.length == 2)   return new Locale(split[0],split[1]);
 else   return new Locale(split[0],split[1],split[2]);
}

private Locale toLocale ( String str ) { if ( str == null ) return null ; String [ ] split = str . split ( "_" ) ; if ( split . length == 0 ) return new Locale ( "" ) ; else if ( split . length == 1 ) return new Locale ( split [ 0 ] ) ; else if ( split . length == 2 ) return new Locale ( split [ 0 ] , split [ 1 ] ) ; else return new Locale ( split [ 0 ] , split [ 1 ] , split [ 2 ] ) ; }
convert string representation to locale object
