博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java Formatter locale()方法与示例
阅读量:2533 次
发布时间:2019-05-11

本文共 1796 字,大约阅读时间需要 5 分钟。

Formatter类的locale()方法 (Formatter Class locale() method)

  • locale() method is available in java.util package.

    locale()方法在java.util包中可用。

  • locale() method is used to returns the locales assign by the construction of this Formatter.

    locale()方法用于返回通过此Formatter的构造分配的语言环境。

  • locale() method is a non-static method, it is accessible with the class object and if we try to access the method with the class name then we will get an error.

    locale()方法是一种非静态方法,可通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • locale() method may throw an exception at the time of returning Locale object.

    返回Locale对象时, locale()方法可能会引发异常。

    FormatterClosedException: This exception may throw when this Formatter close by calling it's close().

    FormatterClosedException:当此Formatter通过调用close()关闭时,可能会引发此异常。

Syntax:

句法:

public Locale locale();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is Locale, it returns locale of this formatter otherwise it returns null.

此方法的返回类型为Locale ,它返回此格式化程序的语言环境,否则返回null。

Example:

例:

// Java program is to demonstrate the example of// locale() method of Formatterimport java.util.*;public class LocaleOfFormatter {
public static void main(String[] args) {
// Instantiates a StringBuffer and Formmatter object StringBuffer sb = new StringBuffer(); Formatter formatt = new Formatter(sb, Locale.UK); // By using format() method is to format a string formatt.format("Hi %s !", "IncludeHelp"); // Display Formatted String System.out.println(formatt); // By using locale() method is to // return the locale set by the formation // of this Formattr System.out.println("formatt.locale(): " + formatt.locale()); }}

Output

输出量

Hi IncludeHelp !formatt.locale(): en_GB

翻译自:

转载地址:http://axtzd.baihongyu.com/

你可能感兴趣的文章
linux学习(3)——vim文本编辑工具
查看>>
快速开发平台如何应用
查看>>
hadoop的理解
查看>>
Java测试当前应用所占用的内存示例
查看>>
网站限制IP访问应该怎么办
查看>>
121. Best Time to Buy and Sell Stock
查看>>
hdu 1005 根据递推公式构造矩阵 ( 矩阵快速幂)
查看>>
安装php扩展
查看>>
mysql统计某一个数据库中有几张表
查看>>
百度移动搜索主要有如下几类结果构成
查看>>
梦断代码最后4章读后感
查看>>
python学习---字符串
查看>>
Python爬虫面试题170道:2019版【1】
查看>>
JavaBean规范
查看>>
第四阶段 15_Linux tomcat安装与配置
查看>>
NAS 创建大文件
查看>>
学习笔记-模块之xml文件处理
查看>>
简单的栈和队列
查看>>
接口测试用例
查看>>
面试:用 Java 实现一个 Singleton 模式
查看>>