Click here to watch on Youtube:
https://www.youtube.com/watch?v=ec2-YfmtPSk&list=UUhwKlOVR041tngjerWxVccw
FormatterDemo.java
Output:
Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/FormatterDemo_format_locale.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/FormatterDemo_format_locale
Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/ef6f73b2185c28cb9cd0149bcd1e9fa0a5b2bdf3/Java_2019/FormatterDemo_format_locale/?at=master
See also:
All JavaEE Videos Playlist 
All JavaEE Videos 
All JAVA EE Links 
Spring Tutorial 
Servlets Tutorial 
All Design Patterns Links 
JDBC Tutorial 
Java Collection Framework Tutorial 
JAVA Tutorial 
Kids Tutorial 
Cooking Tutorial 
https://www.youtube.com/watch?v=ec2-YfmtPSk&list=UUhwKlOVR041tngjerWxVccw
FormatterDemo.java
import java.util.Formatter;
import java.util.Locale;
/**
* public Formatter format(Locale l, String format, Object... args)
*
* Parameters:
*
* l - The locale to apply during formatting.
*
* format - A format string as described in Format string syntax.
*
* args - Arguments referenced by the format specifiers in the format
* string. If there are more arguments than format specifiers, the
* extra arguments are ignored. The maximum number of arguments is
* limited by the maximum dimension of a Java array as defined by The
* Java™ Virtual Machine Specification.
*
* Returns: This formatter
*
*/
public class FormatterDemo
{
public static void main(String[] args)
{
Formatter formatter = new Formatter();
/*
* In this example, the format specifiers, %s and %d are
* replaced with the arguments that follow the format string.
* %s is replaced by "Peter", %d is replaced by 10. %s
* specifies a string, and %d specifies an integer value. All
* other characters are simply used as-is.
*/
formatter.format(Locale.US, "%s age is %d", "Peter", 10);
System.out.println(formatter.out());
formatter.close();
}
}
import java.util.Locale;
/**
* public Formatter format(Locale l, String format, Object... args)
*
* Parameters:
*
* l - The locale to apply during formatting.
*
* format - A format string as described in Format string syntax.
*
* args - Arguments referenced by the format specifiers in the format
* string. If there are more arguments than format specifiers, the
* extra arguments are ignored. The maximum number of arguments is
* limited by the maximum dimension of a Java array as defined by The
* Java™ Virtual Machine Specification.
*
* Returns: This formatter
*
*/
public class FormatterDemo
{
public static void main(String[] args)
{
Formatter formatter = new Formatter();
/*
* In this example, the format specifiers, %s and %d are
* replaced with the arguments that follow the format string.
* %s is replaced by "Peter", %d is replaced by 10. %s
* specifies a string, and %d specifies an integer value. All
* other characters are simply used as-is.
*/
formatter.format(Locale.US, "%s age is %d", "Peter", 10);
System.out.println(formatter.out());
formatter.close();
}
}
Output:
Peter age is 10
Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/FormatterDemo_format_locale.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/FormatterDemo_format_locale
Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/ef6f73b2185c28cb9cd0149bcd1e9fa0a5b2bdf3/Java_2019/FormatterDemo_format_locale/?at=master
See also:
 


 
No comments:
Post a Comment