Conversion from string types to Double and Float in Java

//the first method
String strPi = "3.14";         
float piFloat = Float.parseFloat(strPi);
double piDouble = Double.parseDouble(strPi);

//the second method
String strExp = "2.71828";
double exp = Double.valueOf(strExp);

//the third method
String strHalf = "0,5";
DecimalFormat formatter = new DecimalFormat(); 
DecimalFormatSymbols sfs = new DecimalFormatSymbols(); 
sfs.setDecimalSeparator(','); 
formatter.setDecimalFormatSymbols(sfs); 
double half = 0;
try {
    half = formatter.parse(strHalf).doubleValue();
catch (ParseException e) {
    e.printStackTrace();