當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Java Date getMonth()用法及代碼示例

Java Date 類的 getMonth() 方法返回 0 到 11 之間的值,代表一年中的月份。此方法自 JDK 1.1 版起已棄用,並由 Calender.get(Calender.MONTH) 取代

月份
0 January
1 February
2 March
3 April
4 May
5 June
6 July
7 August
8 September
9 October
10 November
11 December

用法:

@Deprecated
public int getMonth()

參數

NA

返回

它返回此日期對象表示的年份中的月份。

示例

import java.util.Date;

public class JavaDateGetMontExample1 {

	public static void main(String[] args) {
		Date d=new Date();
		System.out.println("Month of the year is :"+d.getMonth());
		}
}

輸出:

Month of the year is :8






相關用法


注:本文由純淨天空篩選整理自 Java Date getMonth() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。