this is the text :
<meta itemprop="duration" content="PT4M32.80000000000001S">
i want to extract PT4M32.80000000000001S and convert it into numeric. I had tried Integer.parseInt() but it gives me NumberFormatException. Would you help please.
this is the text :
<meta itemprop="duration" content="PT4M32.80000000000001S">
i want to extract PT4M32.80000000000001S and convert it into numeric. I had tried Integer.parseInt() but it gives me NumberFormatException. Would you help please.
It depends on what number you want to extract, and if the context is fixed.
Say, you always have PT4M before the double value of 32.80000000000001 that you want to extract.
Here is a sample program:
import java.util.regex.*;
public class HelloWorld{
public static void main(String []args){
String str = "PT4M32.80000000000001S";
Pattern ptrn = Pattern.compile("(?<=PT4M)[\\d.]+");
Matcher matcher = ptrn.matcher(str);
if (matcher.find()) {
System.out.println(matcher.group(0));
Double fl = Double.parseDouble(matcher.group(0));
System.out.println(fl);
}
}
}
Output:
32.80000000000001
32.80000000000001