We are moved to new domain
Click -> www.ehowtonow.com
Friday, 8 May 2015

How to format the String by using Locale

Following example shows how to format the string by using Locale and format() method.

Sample Program

package com.javatutorialcorner.javastring;

import java.util.Locale;

public class StringFormat {

public static void main(String[] args) {
double input = Math.E;
System.out.format("%f%n", input);
System.out.format(Locale.US, "%f%n", input);
System.out.format(Locale.UK, "%f%n", input);
System.out.format(Locale.ITALY, "%f%n", input);
System.out.format(Locale.ITALY, "%-10.4f%n%n", input);
System.out.format(Locale.GERMANY, "%f%n", input);
System.out.format(Locale.GERMANY, "%-10.4f%n%n", input);

}

}


Result


The above code will produce the following result



2.718282
2.718282
2.718282
2,718282
2,7183   

2,718282
2,7183   

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: How to format the String by using Locale Rating: 5 Reviewed By: eHowToNow