Compare the following program?
import java.text.*;
public class NumPar1 {
public static void main(String str[]) {
try {
String number = "23456.789one";
NumberFormat format = NumberFormat.getInstance();
System.out.println("Before parse the number is : " + format.parse(number));
format.setParseIntegerOnly(true);
System.out.println("After parse the number is : " + format.parse(number));
} catch (ParseException pe) {
System.out.println("Parse Exception thrown");
}
}
}
import java.text.*;
public class NumPar2 {
public static void main(String str[]) {
try {
String number = "one23456.789";
NumberFormat format = NumberFormat.getInstance();
System.out.println("Before parse the number is : " + format.parse(number));
format.setParseIntegerOnly(true);
System.out.println("After parse the number is : " + format.parse(number));
} catch (ParseException pe) {
System.out.println("Parse Exception thrown");
}
}
}