SimpleDateFormat类的getDateFormatSymbols()方法用于返回日期和时间格式符号的副本。
用法:
public DateFormatSymbols getDateFormatSymbols()
参数:该方法不带任何参数。
返回值:该方法返回格式符号的副本。
以下示例程序旨在说明SimpleDateFormat的getDateFormatSymbols()方法的用法:
示例1:
// Java code to illustrate
// getDateFormatSymbols() method
import java.text.*;
import java.util.*;
public class SimpleDateFormat_Demo {
public static void main(String[] args)
{
// Initializing the SDF
SimpleDateFormat SDFormat
= new SimpleDateFormat();
// Getting al DateFormatSymbols
DateFormatSymbols DFSymbol
= SDFormat.getDateFormatSymbols();
// Getting the months
String[] month = DFSymbol.getShortMonths();
System.out.println("The Months are: ");
for (int i = 0; i < month.length; i++) {
System.out.println(month[i] + " ");
}
}
}
输出:
The Months are: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
示例2:
// Java code to illustrate
// getDateFormatSymbols() method
import java.text.*;
import java.util.*;
public class SimpleDateFormat_Demo {
public static void main(String[] args)
{
// Initializing the SDF
SimpleDateFormat SDFormat
= new SimpleDateFormat();
// Getting al DateFormatSymbols
DateFormatSymbols DFSymbol
= SDFormat.getDateFormatSymbols();
// Getting the weekdays
String[] days = DFSymbol.getWeekdays();
System.out.println("The days of the week are: ");
for (int i = 0; i < days.length; i++) {
System.out.println(days[i] + " ");
}
}
}
输出:
The days of the week are: Sunday Monday Tuesday Wednesday Thursday Friday Saturday
相关用法
- Java SimpleDateFormat parse()用法及代码示例
- Java SimpleDateFormat equals()用法及代码示例
- Java SimpleDateFormat set2DigitYearStart()用法及代码示例
- Java SimpleDateFormat format()用法及代码示例
- Java SimpleDateFormat toLocalizedPattern()用法及代码示例
- Java SimpleDateFormat toPattern()用法及代码示例
- Java SimpleDateFormat applyPattern()用法及代码示例
- Java SimpleDateFormat setDateFormatSymbols()用法及代码示例
- Java SimpleDateFormat clone()用法及代码示例
- Java SimpleDateFormat get2DigitYearStart()用法及代码示例
- Java SimpleDateFormat hashCode()用法及代码示例
- Java SimpleDateFormat applyLocalizedPattern()用法及代码示例
注:本文由纯净天空筛选整理自Chinmoy Lenka大神的英文原创作品 SimpleDateFormat getDateFormatSymbols() Method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。