- Java.util 包类
- Java.util - 首页
- Java.util - ArrayDeque
- Java.util - ArrayList
- Java.util - Arrays
- Java.util - BitSet
- Java.util - Calendar
- Java.util - Collections
- Java.util - Currency
- Java.util - Date
- Java.util - Dictionary
- Java.util - EnumMap
- Java.util - EnumSet
- Java.util - Formatter
- Java.util - GregorianCalendar
- Java.util - HashMap
- Java.util - HashSet
- Java.util - Hashtable
- Java.util - IdentityHashMap
- Java.util - LinkedHashMap
- Java.util - LinkedHashSet
- Java.util - LinkedList
- Java.util - ListResourceBundle
- Java.util - Locale
- Java.util - Observable
- Java.util - PriorityQueue
- Java.util - Properties
- Java.util - PropertyPermission
- Java.util - PropertyResourceBundle
- Java.util - Random
- Java.util - ResourceBundle
- Java.util - ResourceBundle.Control
- Java.util - Scanner
- Java.util - ServiceLoader
- Java.util - SimpleTimeZone
- Java.util - Stack
- Java.util - StringTokenizer
- Java.util - Timer
- Java.util - TimerTask
- Java.util - TimeZone
- Java.util - TreeMap
- Java.util - TreeSet
- Java.util - UUID
- Java.util - Vector
- Java.util - WeakHashMap
- Java.util 包额外内容
- Java.util - 接口
- Java.util - 异常
- Java.util - 枚举
- Java.util 有用资源
- Java.util - 有用资源
- Java.util - 讨论
Java Calendar getFirstDayOfWeek() 方法
描述
Java Calendar getFirstDayOfWeek() 方法返回一周的第一天。
声明
以下是 java.util.Calendar.getFirstDayOfWeek() 方法的声明
public int getFirstDayOfWeek()
参数
无
返回值
该方法返回一周的第一天。
异常
无
从当前日期日历实例获取一周的第一天示例
以下示例演示了 Java Calendar getFirstDayOfWeek() 方法的使用。我们创建了一个当前日期日历的实例。然后我们获取一周的第一天。使用 switch 语句,我们打印相应的日期。
package com.tutorialspoint; import java.util.Calendar; public class CalendarDemo { public static void main(String[] args) { //create a new calendar Calendar cal = Calendar.getInstance(); //print the first day of the week System.out.println("First day of the week is :" + cal.getFirstDayOfWeek()); int day = cal.getFirstDayOfWeek(); switch (day) { case 1: System.out.println("Sunday"); break; case 2: System.out.println("Monday"); break; case 3: System.out.println("Tuesday"); break; case 4: System.out.println("Wednesday"); break; case 5: System.out.println("Thrusday"); break; case 6: System.out.println("Friday"); break; case 7: System.out.println("Saturday"); } } }
输出
让我们编译并运行上面的程序,这将产生以下结果:
First day of the week is :1 Sunday
从当前日期日历实例和给定的区域设置获取一周的第一天示例
以下示例演示了 Java Calendar getFirstDayOfWeek() 方法的使用。我们创建了一个当前日期和fr区域设置的日历实例。然后我们获取一周的第一天。使用 switch 语句,我们打印相应的日期。
package com.tutorialspoint; import java.util.Calendar; import java.util.Locale; public class CalendarDemo { public static void main(String[] args) { //create a new calendar Calendar cal = Calendar.getInstance(new Locale("fr", "CA")); //print the first day of the week System.out.println("First day of the week is :" + cal.getFirstDayOfWeek()); int day = cal.getFirstDayOfWeek(); switch (day) { case 1: System.out.println("Sunday"); break; case 2: System.out.println("Monday"); break; case 3: System.out.println("Tuesday"); break; case 4: System.out.println("Wednesday"); break; case 5: System.out.println("Thrusday"); break; case 6: System.out.println("Friday"); break; case 7: System.out.println("Saturday"); } } }
输出
让我们编译并运行上面的程序,这将产生以下结果:
First day of the week is :1 Sunday
从当前日期日历实例和自定义区域设置获取一周的第一天示例
以下示例演示了 Java Calendar getFirstDayOfWeek() 方法的使用。我们创建了一个当前日期和en区域设置的日历实例。然后我们获取一周的第一天。使用 switch 语句,我们打印相应的日期。
package com.tutorialspoint; import java.util.Calendar; import java.util.Locale; public class CalendarDemo { public static void main(String[] args) { //create a new calendar Calendar cal = Calendar.getInstance(new Locale("en", "GB")); //print the first day of the week System.out.println("First day of the week is :" + cal.getFirstDayOfWeek()); int day = cal.getFirstDayOfWeek(); switch (day) { case 1: System.out.println("Sunday"); break; case 2: System.out.println("Monday"); break; case 3: System.out.println("Tuesday"); break; case 4: System.out.println("Wednesday"); break; case 5: System.out.println("Thrusday"); break; case 6: System.out.println("Friday"); break; case 7: System.out.println("Saturday"); } } }
输出
让我们编译并运行上面的程序,这将产生以下结果:
First day of the week is :2 Monday
java_util_calendar.htm
广告