当前位置: 首页>>代码示例>>Java>>正文


Java Date.getYear方法代码示例

本文整理汇总了Java中java.util.Date.getYear方法的典型用法代码示例。如果您正苦于以下问题:Java Date.getYear方法的具体用法?Java Date.getYear怎么用?Java Date.getYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Date的用法示例。


在下文中一共展示了Date.getYear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTime

import java.util.Date; //导入方法依赖的package包/类
public void setTime(long time) {
    Date d = new Date(time);
    long dtime;
    int year = d.getYear() + 1900;
    if (year < 1980) {
        dtime = (1 << 21) | (1 << 16);
    }
    else {
        dtime = (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
        d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
        d.getSeconds() >> 1;
    }

    modificationDate = (short)(dtime >> 16);
    modificationTime = (short)(dtime & 0xFFFF);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:17,代码来源:ZioEntry.java

示例2: getAge

import java.util.Date; //导入方法依赖的package包/类
/**根据生日获取年龄
 * @param birthday
 * @return
 */
public static int getAge(Date birthday) {
	if (birthday == null) {
		return 0;
	}
	if (birthday.getYear() > getDateDetail(System.currentTimeMillis())[0]) {
		birthday.setYear(birthday.getYear() - TimeUtil.SYSTEM_START_DATE[0]);
	}

	return getAge(new int[]{birthday.getYear(), birthday.getMonth(), birthday.getDay()});
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:TimeUtil.java

示例3: getSmartBirthday

import java.util.Date; //导入方法依赖的package包/类
/**
 * @param birthday
 * @return
 */
public static String getSmartBirthday(Date birthday) {
	if (birthday == null) {
		return "";
	}
	if (birthday.getYear() > getDateDetail(System.currentTimeMillis())[0]) {
		birthday.setYear(birthday.getYear() - TimeUtil.SYSTEM_START_DATE[0]);
	}

	return getSmartBirthday(birthday.getTime(), false) + " " + (TimeUtil
			.getDateDetail(System.currentTimeMillis())[0] - birthday.getYear()) + "岁";
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:TimeUtil.java

示例4: javaToDosTime

import java.util.Date; //导入方法依赖的package包/类
/**
 * Converts Java time to DOS time.
 */
@SuppressWarnings("deprecation") // Use of date methods
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,代码行数:15,代码来源:ZipUtils.java

示例5: getTime

import java.util.Date; //导入方法依赖的package包/类
private String getTime(long dateLong){


        final long SECOND_TO_LONG=1000l;
        final long MINUTE_TO_LONG=SECOND_TO_LONG*60;
        final long HOUR_TO_LONG=MINUTE_TO_LONG*60;
        final long DAY_TO_LONG=HOUR_TO_LONG*24;

        SimpleDateFormat sdf= new SimpleDateFormat("MM-dd HH:mm");
        SimpleDateFormat sdf2= new SimpleDateFormat("yyyy-MM-dd");

        long ct=System.currentTimeMillis();
        long cost = ct-dateLong*1000l;

        Date ctDate=new Date(ct);
        Date longDate=new Date(dateLong*1000l);

        if(cost<MINUTE_TO_LONG ){
            return cost/SECOND_TO_LONG +"秒前";
        }

        else if(cost<HOUR_TO_LONG){
            return cost/MINUTE_TO_LONG+"分钟前";
        }
        else if(cost<DAY_TO_LONG){
            return cost/HOUR_TO_LONG+"小时前";
        }
        else if(ctDate.getYear()>longDate.getYear()){
            return sdf2.format(longDate);
        }
        else return sdf.format(longDate);

    }
 
开发者ID:moe2studio,项目名称:PangciACG,代码行数:34,代码来源:QuestionDetailAdapter.java

示例6: 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

示例7: feature

import java.util.Date; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public double[] feature(Date date) {
    double[] x = new double[types.length];
    for (int i = 0; i < types.length; i++)
    switch (types[i]) {
        case YEAR:
            x[i] = 1900 + date.getYear();
            break;
        case MONTH:
            x[i] = date.getMonth();
            break;
        case DAY_OF_MONTH:
            x[i] = date.getDate();
            break;
        case DAY_OF_WEEK:
            x[i] = date.getDay();
            break;
        case HOURS:
            x[i] = date.getHours();
            break;
        case MINUTES:
            x[i] = date.getMinutes();
            break;
        case SECONDS:
            x[i] = date.getSeconds();
            break;
        default:
            throw new IllegalStateException("Unknown date feature type: " + types[i]);
    }
    return x;
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:33,代码来源:DateFeature.java

示例8: weekNumber

import java.util.Date; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
static int weekNumber(int year, int month) {
	Date d = new Date(year - 1900, month - 1, 1);
	while (d.getDay() != CalendarUtil.getStartingDayOfWeek()) d.setDate(d.getDate() - 1);
	int y = d.getYear();
	int week = 0;
	while (d.getYear() == y) { d.setDate(d.getDate() - 7); week += 1; }
	return week;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:10,代码来源:SingleDateSelector.java

示例9: getTimeState

import java.util.Date; //导入方法依赖的package包/类
public static boolean getTimeState(long time) {
    boolean output;

    Date last = new Date(time);
    Date current = new Date(System.currentTimeMillis());

    output = last.getYear() < current.getYear() ||
            last.getMonth() < current.getMonth() ||
            last.getDay() < current.getDay() ||
            last.getHours() < current.getHours() ||
            last.getMinutes() < current.getMinutes();

    return output;
}
 
开发者ID:pedromassango,项目名称:Programmers,代码行数:15,代码来源:Util.java

示例10: javaToDosTime

import java.util.Date; //导入方法依赖的package包/类
/**
 * Converts Java time to DOS time.
 */
@SuppressWarnings("deprecation") // Use of date methods
private static long javaToDosTime(long time) {
    Date d = new Date(time);
    int year = d.getYear() + 1900;
    if (year < 1980) {
        return ZipEntry.DOSTIME_BEFORE_1980;
    }
    return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
           d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
           d.getSeconds() >> 1;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:ZipUtils.java

示例11: calcAge

import java.util.Date; //导入方法依赖的package包/类
private int calcAge(Date birthday) {
    return new Date().getYear() - birthday.getYear();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:QNCalc.java

示例12: 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

示例13: inOneDay

import java.util.Date; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
protected boolean inOneDay(Date date1, Date date2) {
    return (date1.getYear() == date2.getYear()) && (date1.getMonth() == date2.getMonth())
            && (date1.getDate() == date2.getDate());
}
 
开发者ID:WillemJiang,项目名称:acmeair,代码行数:6,代码来源:FlightService.java

示例14: isInfFuture

import java.util.Date; //导入方法依赖的package包/类
public static boolean isInfFuture(Date date) {
    return date.getYear() > 8000; // Hacky, but needs to match Ruby's Time::INF_FUTURE
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:TimeUtils.java

示例15: isInfPast

import java.util.Date; //导入方法依赖的package包/类
public static boolean isInfPast(Date date) {
    return date.getYear() < -10000;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:TimeUtils.java


注:本文中的java.util.Date.getYear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。