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 Formatter
import 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

翻译自: https://www.includehelp.com/java/formatter-locale-method-with-example.aspx

Java Formatter locale()方法与示例相关推荐

  1. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  2. java formatter 填充_Java Formatter format()方法及示例

    格式化程序类format()方法 语法:public Formatter format(Locale lo, String frmt, Object... args); public Formatte ...

  3. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  4. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  5. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  6. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  7. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  8. java exec waitfor,Java Process waitFor()方法与示例

    流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...

  9. java arraylist.add(),Java ArrayList add()方法与示例

    ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...

最新文章

  1. Gitlab完整搭建手册+排错
  2. VMware 无法打开内核设备 \\.\Global\vmx86
  3. sdwan安全如何加固?六种安全SD-WAN方案分享
  4. 2015快捷键在哪里设置_炒股软件的选择通达信软件的基本设置
  5. 【双十二】电商们的文案大战,猫狗快被玩坏了!
  6. VTK:创建一个圆锥用法实战
  7. 检测正常和不正常图_医生提醒:激素正常不等于内分泌正常,带你走出内分泌失调误区...
  8. 【编译原理笔记04】语法分析:自顶向下的分析概述、文法转换、LL1文法
  9. C++课后习题第五章17
  10. 仿摩拜单车APP(包括附近车辆、规划路径、行驶距离、行驶轨迹记录,导航等)...
  11. Vdbench工具文件系统测试记录
  12. vagrant up 时提示错误 cound not open file
  13. 内存卡格式化了怎么办?能恢复吗?
  14. html写一个轮播图响应式布局,响应式banner图片轮播布局代码
  15. isFinite函数
  16. React使用cra创建项目,开启装饰器
  17. 统计公司员工喜欢吃的水果,并打印出最喜欢吃的前K中水果【map关联式容器,k/V结构】
  18. 手动删除百度全家桶流氓软件
  19. optimizeinplace
  20. zsore和经验法则(统计学原理)

热门文章

  1. java的栈图形演示
  2. python做什么模型_主题模型初学者指南[Python]
  3. linux db2 归档,DB2的归档模式设置方法
  4. php 构造函数 返回值,php构造函数与析构函数实例分析
  5. python pdb调试基本命令整理
  6. 两个字和三个字一样宽_武汉国庆出行 记好三个字
  7. win7制作ntp服务器,如何将Win7作为NTP服务器
  8. 2021辽宁高考艺考成绩查询系统入口,2019年辽宁省艺考统考成绩查询官方入口
  9. win10 利用安装包 安装 ssh
  10. ubuntu下wps不能输入中文