DecimalFormat SetPositivePrefix() Example
Set the positive prefix.
DecimalFormatclass SetPositivePrefix() method example. This example shows you how to use SetPositivePrefix() method.This method Set the positive prefix.
Here is the code:-
/**
* @Program that Set the positive prefix.
*SetPositivePrefix.java
* Author:-RoseIndia Team
* Date:-13-Jun-2008
*/
import java.text.*;
public class SetPositivePrefix {
public static void main(String[] args) {
// Creates a DecimalFormat object
DecimalFormat d = new DecimalFormat("+0.008");
// Get the positive prefix.
String s=d.getPositivePrefix();
System.out.println("The positive prefix is: "+s);
d.setPositivePrefix("$");
String s1=d.getPositivePrefix();
System.out.println("The positive prefix is: "+s1);
}
} |
Output of the Program
The positive prefix is: +
The positive prefix is: $ |
|