News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

DecimalFormatSymbols Class Examples

Started by VelMurugan, Jan 24, 2009, 10:38 PM

Previous topic - Next topic

VelMurugan

DecimalFormatSymbols SetZeroDigit() Example

Sets the character used for zero.

DecimalFormatSymbolsclass SetZeroDigit() method example. This example shows you how to use SetZeroDigit() method.This method Sets the character used for zero.

Here is the code:-


/**
* @Program that Sets the character used for zero.
* SetZeroDigit.java
* Author:-RoseIndia Team
* Date:-14-Jun-2008
*/
import java.text.*;

public class SetZeroDigit {

    public static void main(String[] args) {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        //Gets the character used for zero.
        char c = dfs.getZeroDigit();
        System.out.println("The character used for zero is: " + c);
        dfs.setZeroDigit('_');
        System.out.println("The character used for zero is: " +dfs.getZeroDigit());
    }
}


Output of the program:-


The character used for zero is: 0
The character used for zero is: _


Source : Codingdiary

VelMurugan

DecimalFormatSymbols SetPerMill() Example

Sets the character used for per mille sign.

DecimalFormatSymbolsclass SetPerMill() method example. This example shows you how to use SetPerMill() method.This method Sets the character used for per mille sign.

Here is the code:-


/**
* @Program that Sets the character used for per mille sign.
* SetPerMill.java
* Author:-RoseIndia Team
* Date:-14-Jun-2008
*/
import java.text.*;

public class SetPerMill {

    public static void main(String[] args) {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        //Gets the character used for per mille sign.
        char c = dfs.getPerMill();
        System.out.println("The character used for per mille sign is: " + c);
        dfs.setPerMill('|');
        System.out.println("The character used for per mille sign is: " +dfs.getPerMill());
    }
}


Output of the program:-


The character used for per mille sign is: ‰
The character used for per mille sign is: |

VelMurugan

DecimalFormatSymbols SetPercent() Example

Sets the character used for percent sign.

DecimalFormatSymbolsclass SetPercent() method example. This example shows you how to use SetPercent() method.This method Sets the character used for percent sign.

Here is the code:-

/**
* @Program that Sets the character used for percent sign.
* SetPercent.java
* Author:-RoseIndia Team
* Date:-14-Jun-2008
*/
import java.text.*;

public class SetPercent {

    public static void main(String[] args) {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        //Gets the character used for percent sign.
        char c = dfs.getPercent();
        System.out.println("The character used for percent sign is: " + c);
        dfs.setPercent('@');
        System.out.println("The character used for percent sign is: " +dfs.getPercent());
       
    }
}


Output of the program:-

The character used for percent sign is: %
The character used for percent sign is: @

VelMurugan

DecimalFormatSymbols SetPatternSeparator() Example

Sets the character used to separate positive and negative subpatterns in a pattern.

DecimalFormatSymbolsclass SetPatternSeparator() method example. This example shows you how to use SetPatternSeparator() method.This method Sets the character used to separate positive and negative subpatterns in a pattern.

Here is the code:-

/**
* @Program that Sets the character used to separate positive and negative
* subpatterns in a pattern.
* SetPatternSeparator.java
* Author:-RoseIndia Team
* Date:-14-Jun-2008
*/
import java.text.*;
public class SetPatternSeparator {

    public static void main(String[] args) {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        //Gets the character used to separate positive and negative subpatterns in a pattern.
        char c = dfs.getPatternSeparator();
        System.out.println("The character used to separate positive and negative subpatterns is: " + c);
        dfs.setPatternSeparator('%');
        System.out.println("The character used to separate positive and negative subpatterns is: " +dfs.getPatternSeparator());
    }
}


Output of the program:-

The character used to separate positive and negative subpatterns is: ;
The character used to separate positive and negative subpatterns is: %

VelMurugan

DecimalFormatSymbols SetNaN() Example

Sets the string used to represent "not a number".

DecimalFormatSymbolsclass SetNaN() method example. This example shows you how to use SetNaN() method.This method Sets the string used to represent "not a number".

Here is the code:-

/**
* @Program that Sets the string used to represent "not a number".
* SetNaN.java
* Author:-RoseIndia Team
* Date:-14-Jun-2008
*/
import java.text.*;
import java.util.*;

public class SetNaN {

    public static void main(String[] args) {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        //Gets the string used to represent "not a number".       
        String c = dfs.getNaN();
        System.out.println("The string used to represent not a number is: " + c);
        dfs.setNaN("##");
        System.out.println("The string used to represent not a number is: " +dfs.getNaN());
    }
}

Output of the program:-

The string used to represent not a number is: �
The string used to represent not a number is: ##

VelMurugan

DecimalFormatSymbols SetMonetaryDecimalSeparator() Example

Sets the monetary decimal separator.

DecimalFormatSymbolsclass SetMonetaryDecimalSeparator() method example. This example shows you how to use SetMonetaryDecimalSeparator() method.This method Sets the monetary decimal separator.

Here is the code:-


/**
* @Program that Sets the monetary decimal separator.
* SetMonetaryDecimalSeparator.java
* Author:-RoseIndia Team
* Date:-14-Jun-2008
*/
import java.text.*;
import java.util.*;

public class SetMonetaryDecimalSeparator {

    public static void main(String[] args) {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        char c = dfs.getMonetaryDecimalSeparator();
        System.out.println("The character used to represent minus sign: " + c);
        dfs.setMonetaryDecimalSeparator('~');
        System.out.println("The character used to represent minus sign: " +dfs.getMonetaryDecimalSeparator());
    }
}


Output of the program:-

The character used to represent minus sign: .
The character used to represent minus sign: ~

VelMurugan

DecimalFormatSymbols SetMinusSign() Example

Sets the character used to represent minus sign.

DecimalFormatSymbolsclass SetMinusSign() method example. This example shows you how to use SetMinusSign() method.This method Sets the character used to represent minus sign.

Here is the code:-

/**
* @Program that Sets the character used to represent minus sign.
* SetMinusSign.java
* Author:-RoseIndia Team
* Date:-14-Jun-2008
*/
import java.text.*;
import java.util.*;

public class SetMinusSign {

    public static void main(String[] args) {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        char c=dfs.getMinusSign();
        System.out.println("The character used to represent minus sign: "+c);
        dfs.setMinusSign('=');
        System.out.println("The character used to represent minus sign: "+dfs.getMinusSign());
       
    }
}


Output of the program:-

The character used to represent minus sign: -
The character used to represent minus sign: =