Преобразование строки...
Листинг 6.40. Преобразование строки в значение (Util.java)
static public int getInt( String s ) { if( s == null || s.equals( "" ) ) { return 0; } return Integer.parseInt( s );
}
static public Integer getInteger( String s ) { if( s == null || s.equals( "" ) ) { return null; } return new Integer( s );
}
static public float getFloat( String s ) { if( s == null || s.equals( "" ) ) { return 0.0f; } return Float.parseFloat( s );
}
static public double getDouble( String s ) { if( s == null || s.equals( "" ) ) { return 0.0; } return Double.parseDouble( s );
}
}
Содержание раздела