java calendar_Java Calendar getDisplayNames()方法與示例

java calendar

日歷類的getDisplayNames()方法 (Calendar Class getDisplayNames() method)

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

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

  • getDisplayNames() method is used to return Map that contains all field names of the calendar will be updated in the given field(fi) values in the given style(st) and Locale(lo).

    getDisplayNames()方法用于返回包含日歷所有字段名稱的Map,這些日歷名稱將在給定style(st)和Locale(lo)的給定field(fi)值中更新。

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

    getDisplayNames()方法是一個非靜態方法,可通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • getDisplayNames() method may throw an exception at the time of returning Map object.

    getDisplayNames()方法在返回Map對象時可能會引發異常。

    • IllegalArgumentException: This exception may throw when the given field(fi) or style(st) are not valid.IllegalArgumentException :如果給定的field(fi)或style(st)無效,則可能引發此異常。
    • NullPointerException: This exception may throw when the given parameter Locale(lo) is null exists.NullPointerException :如果給定參數Locale(lo)為null,則可能引發此異常。

Syntax:

句法:

    public Map getDisplayNames(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 Map object that contains names display in the given style and locale and their desired field(fi) values otherwise it returns null when no string denotation exists.

該方法的返回類型為String ,它返回Map對象,該對象包含以給定樣式和語言環境顯示的名稱以及所需的field(fi)值,否則,當不存在任何字符串符號時,它返回null。

Example:

例:

// Java Program to demonstrate the example of
// Map getDisplayNames() method of Calendar
import java.util.*;
public class GetDisplayNames {
public static void main(String args[]) {
// Instantiating a Calendar object
Calendar ca = Calendar.getInstance();
// Instantiating a Locale object
Locale lo = Locale.getDefault();
// By using getDisplayNames() method is to
// display the names
Map < String, Integer > m = ca.getDisplayNames(Calendar.DAY_OF_WEEK,
Calendar.LONG, lo);
NavigableMap < String, Integer > nm = new TreeMap < String, Integer > (m);
// Displaying the results 
System.out.println(" ca.getDisplayNames(): " + nm);
}
}

Output

輸出量

ca.getDisplayNames(): {Friday=6, Monday=2, Saturday=7, Sunday=1, Thursday=5, Tuesday=3, Wednesday=4}

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

java calendar

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541859.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541859.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541859.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Linux如何查找大文件或目錄總結

轉載&#xff1a;http://www.cnblogs.com/kerrycode/p/4391859.html 在Windows系統中&#xff0c;我們可以使用TreeSize工具查找一些大文件或文件夾&#xff0c;非常的方便高效&#xff0c;在Linux系統中&#xff0c;如何去搜索一些比較大的文件呢&#xff1f;下面我整理了一下…

java編寫簡單郵件_Javamail,編寫簡單的程序發送郵件

代碼&#xff1a;package com.dai.mail; import java.util.Properties; import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.In…

java calendar_Java Calendar getLeastMaximum()方法與示例

java calendarCalendar類的getLeastMaximum()方法 (Calendar Class getLeastMaximum() method) getLeastMaximum() method is available in java.util package. getLeastMaximum()方法在java.util包中可用。 getLeastMaximum() method is used to get the least maximum value …

Shell 標準輸入、輸出和錯誤

防偽碼&#xff1a;桃花潭水深千尺&#xff0c;不及汪倫送我情。文件描述符&#xff08;fd&#xff09;&#xff1a;文件描述符是一個非負整數&#xff0c;在打開現存文件或新建文件時&#xff0c;內核會返回一個文件描述符&#xff0c;讀寫文件也需要使用文件描述符來訪問文件…

java需要會的工具_Java開發者必備的幾款工具,一定要掌握!

原標題&#xff1a;Java開發者必備的幾款工具&#xff0c;一定要掌握&#xff01;NotepadNotepad是用于編輯xml、腳本以及記筆記的最佳工具。這個工具的最好部分在于&#xff0c;你在Notepad上打開的任何一個文檔&#xff0c;在關閉后都會有一個殘留文檔&#xff0c;它有助于在…

java的equals方法_Java LocalDateTime類| 帶示例的equals()方法

java的equals方法LocalDateTime類equals()方法 (LocalDateTime Class equals() method) equals() method is available in java.time package. equals()方法在java.time包中可用。 equals() method is used to check whether this date-time and the given object are equal or…

portlet java_Java Portlet 規范概述

前言1、portlet是一種類似servlet的規范。2、servlet是web組件&#xff0c;portlet也是web組件。參考1、百度百科&#xff1a;portlethttp://baike.baidu.com/link?urlvMzVwpkf5WzOL23GLkgM4C5C7Sarqh1XXShS73L7k-MbGgM0ooZ4Dl2Efor3bb4tZmmLo6v-muG5UW7_CYMTUahttp://hintcnu…

Java LocalDate類| minusWeeks()方法與示例

LocalDate類minusWeeks()方法 (LocalDate Class minusWeeks() method) minusWeeks() method is available in java.time package. minusWeeks()方法在java.time包中可用。 minusWeeks() method is used to subtract the given weeks from this LocalDate and return the LocalD…

Android推薦的幾本書

2019獨角獸企業重金招聘Python工程師標準>>> 第一階段 <<第一行代碼Android>><<瘋狂Android>>第二階段 <<Android開發藝術探索>><<Android群英傳>>Android源碼 第三階段 <<Android開發藝術探索>><&…

java數據類型后綴_java基礎知識---基本數據類型

1)四種整數類型(byte、short、int、long)&#xff1a;byte&#xff1a;8 位&#xff0c;用于表示最小數據單位&#xff0c;如文件中數據&#xff0c;-128~127short&#xff1a;16 位&#xff0c;很少用&#xff0c;-32768 ~ 32767int&#xff1a;32 位、最常用&#xff0c;-2^3…

duration java_Java Duration類| minusMillis()方法與示例

duration java持續時間類minusMillis()方法 (Duration Class minusMillis() method) minusMillis() method is available in java.time package. minusMillis()方法在java.time包中可用。 minusMillis() method is used to subtract the given duration in milliseconds from t…

Thread 和 Runnable創建新線程的區別,Runnable可以共享線程類的實例屬性

Thread實現多線程&#xff1a; public class Thread2 extends Thread{ public int i; public void run(){ for(; i < 100 ;i) { System.out.println(getName() " " i); } } public static void main(String[] args){ for (int j 0; j < 100; j) { System…

java編程求最小公約數_java求最大公約數與最小公倍數

public class Gongyueshu{public static void main(String[] args){//從控制臺輸入兩個數據int m Integer.parseInt(args[0]);int n Integer.parseInt(args[1]);int y 1 ;int b 1;if (m > 0 && n >0){//先判定這兩個數是否為倍數關系&#xff0c;如果是則小數…

tdr上升時間什么設定_TDR的完整形式是什么?

tdr上升時間什么設定TDR&#xff1a;時域反射儀/車票寄存收據/定期存款收據 (TDR: Time Domain Reflectometer/ Ticket Deposit Receipt/ Term Deposit Receipt) 1)TDR&#xff1a;時域反射儀 (1) TDR: Time Domain Reflectometer) TDR is an abbreviation of the "Time D…

【java】反射+poi 導出excel

2019獨角獸企業重金招聘Python工程師標準>>> 反射 導出的數組轉變成對象 private static Object expexcelMaptobean(Class<?> cobj,Map<String,String> map,int[] expColums,String[] params) throws InstantiationException, IllegalAccessException…

css設置背景圖片大小_如何使用CSS設置背景圖片大小?

css設置背景圖片大小Introduction: 介紹&#xff1a; As we all know that the images are a very responsive yet very creative way to display your web page or website to the users. The images also play a major role in indulging users to websites or web pages. T…

java gc的特性_Java12新特性 -- 可中斷的G1 Mixed GC

Java 12 中增強了 G1 垃圾收集器關于混合收集集合的處理策略&#xff0c;這節主要介紹在 Java 12 中同時也對 G1垃圾回收器進行了改進&#xff0c;使其能夠在空閑時自動將 Java 堆內存返還給操作系統&#xff0c;這也是 Java 12 中的另外一項重大改進。目前 Java 11 版本中包含…

在Python3中將字符串轉換為字節的最佳方法

To convert a string to bytes, there are more than one way, 要將字符串轉換為字節&#xff0c;有多種方法&#xff0c; Approach 1: use encode() method 方法1&#xff1a;使用encode()方法 test_str "include_help"print(type(test_str))test_bytes test_st…

【Java】PMD規則學習(1) --字符串比較

PMD是一款采用BSD協議發布的Java程序代碼檢查工具。該工具可以做到檢查Java代碼中是否含有未使用的變量、是否含有空的抓取塊、是否含有不必要的對象等。該軟件功能強大&#xff0c;掃描效率高&#xff0c;是Java程序員debug的好幫手。 PMD支持的編輯器包括&#xff1a;JDevelo…

php定義object數據類型,PHP數據類型(4):對象object

//創建一個類class Student{//定義屬性public $name XuGZh;public $age 20;public $sex 男;//定義方法public function getInfo(){//當前對象中訪問自己屬性用偽變量$thisreturn my name:.$this->name..my age:.$this->age..my sex:.$this->sex;}}對象初始化:要創建…