當前位置: 首頁>>代碼示例>>Java>>正文


Java Date.getMonth方法代碼示例

本文整理匯總了Java中java.util.Date.getMonth方法的典型用法代碼示例。如果您正苦於以下問題:Java Date.getMonth方法的具體用法?Java Date.getMonth怎麽用?Java Date.getMonth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Date的用法示例。


在下文中一共展示了Date.getMonth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getQuarter

import java.util.Date; //導入方法依賴的package包/類
/**
 * 取季度
 * 
 * @param date
 * @return
 */
@SuppressWarnings("deprecation")
public static int getQuarter(Date date) {
	if (date.getMonth() == 0 || date.getMonth() == 1 || date.getMonth() == 2) {
		return 1;
	} else if (date.getMonth() == 3 || date.getMonth() == 4 || date.getMonth() == 5) {
		return 2;
	} else if (date.getMonth() == 6 || date.getMonth() == 7 || date.getMonth() == 8) {
		return 3;
	} else if (date.getMonth() == 9 || date.getMonth() == 10 || date.getMonth() == 11) {
		return 4;
	} else {
		return 0;

	}
}
 
開發者ID:mumucommon,項目名稱:mumu-core,代碼行數:22,代碼來源:DateUtils.java

示例2: getNextMonth

import java.util.Date; //導入方法依賴的package包/類
/**
 * 獲取當天的下一個月
 */
public static String getNextMonth() {
    Date t = new Date();
    String nmonth = new String();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    try {
        //t=sdf.parse(now);
        Date nextmonth = new Date((t.getYear() + (t.getMonth() + 1) / 12),
                (t.getMonth() + 1) % 12, t.getDate());
        nmonth = sdf.format(nextmonth.getTime());
    } catch (Exception e) {

        e.printStackTrace();
    }
    return nmonth;
}
 
開發者ID:imliujun,項目名稱:LJFramework,代碼行數:20,代碼來源:TimeUtils.java

示例3: getCreateTimes

import java.util.Date; //導入方法依賴的package包/類
private String getCreateTimes(String dates)
   {
       Date old = toDate(dates);
       Date nowtime = new Date(System.currentTimeMillis());
       long values = nowtime.getTime() - old.getTime();
       values = values / 1000;
// Log.e(TAG, "====values  time===" + values);
       if (values < 60 && values > 0)
{
           return  values + "秒前";
       }
       if (values > 60 && values < 60 * 60)
{
           return values / 60 + "分鍾前";
       }
       if (values < 60 * 60 * 24 && values > 60 * 60)
{
           return values / 3600 + "小時前";
       }
       if (values < 60 * 60 * 24 * 2 && values > 60 * 60 * 24)
{
           return "昨天";
       }
       if (values < 60 * 60 * 3 * 24 && values > 60 * 60 * 24 * 2)
{
           return  "前天";
       }
       if (values < 60 * 60 * 24 * 30 && values > 60 * 60 * 24 * 3)
{
           return  values / (60 * 60 * 24) + "天前";
       }
       if (values < 60 * 60 * 24 * 365 && values > 60 * 60 * 24 * 30)
{
    return nowtime.getMonth() - old.getMonth() + "個月前";
       }
       return  values / (60 * 60 * 24 * 30 * 365) + "年前";
   }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:38,代碼來源:HelpsMainAdapter.java

示例4: happensHere

import java.util.Date; //導入方法依賴的package包/類
private boolean happensHere(Date start, Date current, Date end) {
    if (start.getYear() <= current.getYear() && start.getMonth() <= current.getMonth() && start.getDate() <= current.getDate()) {
        if (current.getYear() <= end.getYear() && current.getMonth() <= end.getMonth() && current.getDate() <= end.getDate()) {
            return true;
        }
    }
    return false;
}
 
開發者ID:Onelio,項目名稱:ConnectU,代碼行數:9,代碼來源:HorarioRequest.java

示例5: isToday

import java.util.Date; //導入方法依賴的package包/類
public static boolean isToday(Date date) {
    Date now = new Date();
    boolean result = true;
    result &= date.getYear() == now.getYear();
    result &= date.getMonth() == now.getMonth();
    result &= date.getDate() == now.getDate();
    return result;
}
 
開發者ID:ZHENFENG13,項目名稱:My-Blog,代碼行數:9,代碼來源:DateKit.java

示例6: getShortTimeText

import java.util.Date; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static String getShortTimeText(Long oldTime) {
	Date time = parseDate(oldTime, TimeFormat);
	Date now = new Date();
	String format = "yyyy-MM-dd HH:mm";
	if (time.getYear() == now.getYear()) {
		format = format.substring("yyyy-".length());
		if (time.getMonth() == now.getMonth() && time.getDay() == now.getDay()) {
			format = format.substring("MM-dd ".length());
		}
	}
	return formatDate(time, format);
}
 
開發者ID:DataAgg,項目名稱:DaUtil,代碼行數:14,代碼來源:TextUtils.java

示例7: javaToDosTime

import java.util.Date; //導入方法依賴的package包/類
public static long javaToDosTime(long time) {
    Date d = new Date(time);
    int year = d.getYear() + 1900;
    if (year < 1980) {
        return (1 << 21) | (1 << 16);
    }
    return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
           d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
           d.getSeconds() >> 1;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:ZipUtils.java

示例8: get6days

import java.util.Date; //導入方法依賴的package包/類
public static String[] get6days(boolean returnString)
{
    Date d=getToday();

    String [] days=new String[6];
    for (int i=0;i<6;i++)
    {
        Date t=add(d,i-2);
        days[i]=t.getMonth()+1+"."+t.getDate();
    }
    return days;
}
 
開發者ID:gojuukaze,項目名稱:healthgo,代碼行數:13,代碼來源:WeatherChartView.java

示例9: isToday

import java.util.Date; //導入方法依賴的package包/類
/**
 * 測試是否是當天
 * 
 * @param date
 *            某一日期
 * @return true 今天, false-不是
 */
@SuppressWarnings("deprecation")
public static boolean isToday(Date date) {

    Date now = new Date();
    boolean result = true;
    result &= date.getYear() == now.getYear();
    result &= date.getMonth() == now.getMonth();
    result &= date.getDate() == now.getDate();
    return result;
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:18,代碼來源:DateTimeHelper.java

示例10: clear

import java.util.Date; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static void clear(String dumpName) {
    try {
        ConcurrentLinkedDeque<CompilationStatistics> snapshot = list;
        long snapshotZeroTime = zeroTime;

        list = new ConcurrentLinkedDeque<>();
        zeroTime = System.nanoTime();

        Date now = new Date();
        String dateString = (now.getYear() + 1900) + "-" + (now.getMonth() + 1) + "-" + now.getDate() + "-" + now.getHours() + "" + now.getMinutes();

        dumpCompilations(snapshot, dumpName, dateString);

        try (FileOutputStream fos = new FileOutputStream("timeline_" + dateString + "_" + dumpName + ".csv", true); PrintStream out = new PrintStream(fos)) {

            long[] timeSpent = new long[10000];
            int maxTick = 0;
            for (CompilationStatistics stats : snapshot) {
                long start = stats.startTime - snapshotZeroTime;
                long duration = stats.duration;
                if (start < 0) {
                    duration -= -start;
                    start = 0;
                }

                int tick = (int) (start / RESOLUTION);
                long timeLeft = RESOLUTION - (start % RESOLUTION);

                while (tick < timeSpent.length && duration > 0) {
                    if (tick > maxTick) {
                        maxTick = tick;
                    }
                    timeSpent[tick] += Math.min(timeLeft, duration);
                    duration -= timeLeft;
                    tick++;
                    timeLeft = RESOLUTION;
                }
            }
            String timelineName = System.getProperty("stats.timeline.name");
            if (timelineName != null && !timelineName.isEmpty()) {
                out.printf("%s%c", CSVUtil.Escape.escape(timelineName), CSVUtil.SEPARATOR);
            }
            for (int i = 0; i < maxTick; i++) {
                out.printf("%d%c", normalize(timeSpent[i]), CSVUtil.SEPARATOR);
            }
            // print last column
            out.printf("%d", normalize(timeSpent[maxTick]));
            out.println();
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:55,代碼來源:CompilationStatistics.java

示例11: toRPCDate

import java.util.Date; //導入方法依賴的package包/類
public static CalDate toRPCDate(Date date) {
    return new CalDate(date.getYear() + 1900, date.getMonth() + 1, date.getDate());
}
 
開發者ID:blackbluegl,項目名稱:calendar-component,代碼行數:4,代碼來源:DateConstants.java

示例12:

import java.util.Date; //導入方法依賴的package包/類
public static Integer 月份(Date $時間) {
		return $時間.getMonth();
}
 
開發者ID:MikaGuraN,項目名稱:HL4A,代碼行數:4,代碼來源:時間工具.java

示例13: IsToday

import java.util.Date; //導入方法依賴的package包/類
public boolean IsToday() {
    Calendar calendar = Calendar.getInstance();
    Date now = calendar.getTime();
    return _begin.getDay() == now.getDay() && _begin.getMonth() == now.getMonth() && _begin.getYear() == now.getYear();
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:6,代碼來源:CalendarEntryDto.java

示例14: getMonthsDifference

import java.util.Date; //導入方法依賴的package包/類
public static int getMonthsDifference(Date date1, Date date2) {
    int m1 = date1.getYear() * 12 + date1.getMonth();
    int m2 = date2.getYear() * 12 + date2.getMonth();
    return m2 - m1 + 1;
}
 
開發者ID:akashdeepsingh9988,項目名稱:Cybernet-VPN,代碼行數:6,代碼來源:X509Utils.java

示例15: getToday

import java.util.Date; //導入方法依賴的package包/類
public static Date getToday()
{
    Date d=new Date();
    return new Date(d.getYear(),d.getMonth(),d.getDate());
}
 
開發者ID:gojuukaze,項目名稱:healthgo,代碼行數:6,代碼來源:DateTimeHelper.java


注:本文中的java.util.Date.getMonth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。