当前位置: 首页>>代码示例>>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;未经允许,请勿转载。