NumberFormat Parse1() Example
Returns a Long
NumberFormatclass Parse1() method example. This example shows you how to use Parse1() method.This method Returns a Long
Here is the code:-
/**
* @Program that Parses text from the beginning of the given string to produce
* a number
* Parse1.java
* Author:-RoseIndia Team
* Date:-17-Jun-2008
*/
import java.text.*;
import java.util.*;
public class Parse1 {
public static void main(String[] args)throws ParseException {
//Creating Numberformat instance
NumberFormat nf = NumberFormat.getInstance();
ParsePosition ps=new ParsePosition(2) ;
Number n=nf.parse("123456",ps);
System.out.println("Number produced after parsing is: "+n);
}
} |
Output of the program:-
| Number produced after parsing is: 3456 |
|