當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。