日历类的getDisplayName()方法 (Calendar Class getDisplayName() method)

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

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

  • getDisplayName() method is used to return string denotation of the given calendar field(fi) in the specified style(st) and locale(lo).

    getDisplayName()方法用于以指定的style(st)和locale(lo)返回给定日历字段(fi)的字符串表示形式。

  • getDisplayName() 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.

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

  • getDisplayName() method may throw an exception at the time of returning the calendar field with the given pattern.

    使用给定的模式返回日历字段时, getDisplayName()方法可能会引发异常。

    • IllegalArgumentException: This exception may throw when calendar field or style values are not valid.IllegalArgumentException :如果日历字段或样式值无效,则可能引发此异常。
    • NullPointerException: This exception may throw when the given parameter Locale(lo) is null exists.NullPointerException :如果给定参数Locale(lo)为null,则可能引发此异常。

Syntax:

句法:

    public String getDisplayName(int fi, int st, Locale lo);

Parameter(s):

参数:

  • int fi – it represents the field(fi) of this Calendar.

    int fi –它代表此日历的字段(fi)。

  • int st – it represents the style that will implemented to the string denotation.

    int st –它表示将对字符串符号实施的样式。

  • Locale lo – it represents the locale of the string denotation.

    语言环境lo –它表示字符串符号的语言环境。

Return value:

返回值:

The return type of the method is String, it returns string denotation of the given calendar field(fi) in the given style(st) or locale(lo) when exists otherwise it returns null when no string denotation exists.

该方法的返回类型为String ,如果存在,它将以给定的style(st)或locale(lo)返回给定日历字段(fi)的字符串表示形式,否则,如果不存在任何字符串表示形式,则返回null。

Example:

例:

// Java Program to demonstrate the example of
// String getDisplayName() method of Calendar
import java.util.*;
public class GetDisplayName {public static void main(String args[]) {// Creating two objects of Locale
Locale lo1 = new Locale("Japanese", "Japan");
Locale lo2 = new Locale("Telgu", "Tamil");
// Display lo1 and lo2
System.out.println("Locale 1: " + lo1);
System.out.println("Locale 2: " + lo2);
// By using getDisplayName() method
// is to display the name of locale 1
String s = lo1.getDisplayName();
// Displaying the results
System.out.println("lo1.getDisplayName(): " + s);
// By using getDisplayName() method
// is to display the name of locale
s = lo2.getDisplayName();
// Displaying the results
System.out.println("lo2.getDisplayName(): " + s);
}
}

Output

输出量

Locale 1: japanese_JAPAN
Locale 2: telgu_TAMIL
lo1.getDisplayName(): japanese (JAPAN)
lo2.getDisplayName(): telgu (TAMIL)

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

Java Calendar getDisplayName()方法与示例相关推荐

  1. cdate在java中_Java Calendar.add方法代码示例

    本文整理汇总了Java中java.util.Calendar.add方法的典型用法代码示例.如果您正苦于以下问题:Java Calendar.add方法的具体用法?Java Calendar.add怎 ...

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

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

  3. java的calendar的get_Java Calendar get()方法与示例

    日历类get()方法get()方法在java.util包中可用. get()方法用于检索此Calendar的给定参数fi(field)的值. get()方法是一个非静态方法,可通过类对象访问,如果尝试 ...

  4. python中weekday_Python calendar.weekday方法代码示例

    本文整理汇总了Python中calendar.weekday方法的典型用法代码示例.如果您正苦于以下问题:Python calendar.weekday方法的具体用法?Python calendar. ...

  5. java calendar.add方法_Java Calendar add()方法与示例

    日历类add()方法add()方法在java.util包中可用. add()方法用于对指定的cal_fi(日历字段)执行相加或相减的时间量. add()方法是一个非静态方法,可通过类对象访问,如果尝试 ...

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

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

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

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

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

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

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

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

最新文章

  1. linux 回环接口实现,Linux回环接口-----(loop-back/loopback)
  2. 黑马程序员--java基础--其他对象
  3. Unity TIP4: 带泛型参数的接口注入(interface,generic)
  4. 才子佳人文学传统的戏拟与嘲仿
  5. 阿里云一键建站产品,阿里云自营建站-中小企业建站首选
  6. python 分位数计算代码_Python数据分析第十一节 数据运算
  7. 3.5 SE93创建自建表事务码
  8. 【AI视野·今日CV 计算机视觉论文速览 第198期】Fri, 14 May 2021
  9. unity3d 使用GL 方式画线
  10. nofollow标签_网站Nofollow标签的应用场景
  11. 12 mysql性能抖动
  12. for循环、while循环、break跳出循环、continue结束本次循环、exit退出脚本
  13. day20 文件上传
  14. 医药行业进销存软件 零售药店管理软件
  15. 金蝶生成凭证模板_凭证模板
  16. 【Mockplus教程】MAC上安装Mockplus
  17. access和tagware_NDoc 用户指南
  18. 华为p10和p10plus区别_华为P10和华为P10Plus怎么样?哪个更值得买?华为P10与P10Plus区别对比...
  19. AEC-Q100和ISO26262 ASIL-B双重认证
  20. 活动回顾(PPT+视频)|Python开发者的年度聚会,我们的现场直击!

热门文章

  1. oracle中修改多个字段默认值_利用VBA代码在已有的数据表中删除、添加、修改字段...
  2. arma模型_Eviews经典案例 | 初学者必看!ARMA模型精讲
  3. jspdf html转换pdf,使用jspdf将HTML转换为pdf时出错
  4. ios 通过kvc修改属性会触发kvo_iOS开发-KVC和KVO的理解
  5. python怎么全选_有没有一种方法可以在Python网页上模拟“全选复制粘贴”?
  6. shell判断字符串是否为数字
  7. 洛谷P2015 二叉苹果树【树形dp】
  8. Save the Room【找规律】
  9. In Compiler.php line 36: Please provide a valid cache path.
  10. Linux下 -bash: php: command not found 命令找不到