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


Java Date.getHours方法代碼示例

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


在下文中一共展示了Date.getHours方法的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:uhuru-mobile,項目名稱:mobile-store,代碼行數:17,代碼來源:ZioEntry.java

示例2: getFriendlyDate

import java.util.Date; //導入方法依賴的package包/類
/**
 * 獲取友好時間表示
 * @param s
 * @return
 */
public static String getFriendlyDate(String s){
    Date old=toDate(s);
    Date nowTime=new Date(System.currentTimeMillis());
    long values=nowTime.getTime()-old.getTime();
    values/=1000;
    if(values>=0&&values<60){
        return values+"秒前";
    }
    if(values>=60&&values<60*60){
        return values/60+"分鍾前";
    }
    if(values>=60*60&&values<60*60*24){
        return values/3600+"小時前";
    }
    if(values>=60*60*24&&values<60*60*24*2){
        return "昨天:"+old.getHours()+":"+old.getTime();
    }
    if(values>=60*60*24*2&&values<60*60*24*3){
        return "前天:"+old.getHours()+":"+old.getTime();
    }
    return s;
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:28,代碼來源:DateUtil.java

示例3: isEqual

import java.util.Date; //導入方法依賴的package包/類
/**
 * @todo have to solve the milli second problem that which is there.!!
 * @param convDate
 * @param expectedDate
 * @return
 */
@SuppressWarnings("deprecation")
protected static boolean isEqual(Date convDate, Date expectedDate)
{
  GregorianCalendar convGcal = new GregorianCalendar();
  convGcal.setTime(convDate);

  GregorianCalendar expGcal = new GregorianCalendar();
  expGcal.setTime(expectedDate);

  // -= Simon Lessard =-
  // FIXME: Switch to Calendar methods
  return
    (convDate.getSeconds() == expectedDate.getSeconds()) &&
    (convDate.getYear()    == expectedDate.getYear())    &&
    (convDate.getMonth()   == expectedDate.getMonth())   &&
    (convDate.getDate()    == expectedDate.getDate())    &&
    (convDate.getHours()   == expectedDate.getHours())   &&
    (convDate.getMinutes() == expectedDate.getMinutes()) ;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:26,代碼來源:DateTimeConverterTestCase.java

示例4: isBetweenTime

import java.util.Date; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static boolean isBetweenTime(int startHour, int startMin, int endHour, int endMin)
{
    Date cD = getCurrentDate();
    int hour = cD.getHours();
    int min = cD.getMinutes();
    
    long cTime = hour * 60 + min;
    
    long startTime = startHour * 60 + startMin;
    long endTime = endHour * 60 + endMin;
    if (cTime > startTime && cTime < endTime)
    {
        return true;
    }
    return false;
}
 
開發者ID:zhuyu1022,項目名稱:amap,代碼行數:18,代碼來源:MIP_DateUtil.java

示例5: setTime

import java.util.Date; //導入方法依賴的package包/類
private void setTime() {
  Date now = new Date();
  int hours = now.getHours();
  hours = (hours>12)?hours-12:hours;
  int minutes  = now.getMinutes();
  int h1 = hours/10;
  int h2 = hours - h1*10;
  int m1 = minutes/10;
  int m2 = minutes -  m1*10;
  
  Log.d(TAG, String.format("%d:%d -> %d %d: %d %d",hours, minutes, h1, h2, m1, m2));
  
  h1View.setImageResource( numToRes(h1) );
  h2View.setImageResource( numToRes(h2) );
  m1View.setImageResource( numToRes(m1) );
  m2View.setImageResource( numToRes(m2) );
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:18,代碼來源:ClockActivity.java

示例6: GetChineseHour

import java.util.Date; //導入方法依賴的package包/類
public String GetChineseHour(Date dt, Date _date) {

        int _hour, offset, i;
        int _minute = 0;
        int indexGan;
        String ganHour, zhiHour;
        String tmpGan;

        //計算時辰的地支
        _hour = dt.getHours();   //獲得當前時間小時
        _minute = dt.getMinutes();  //獲得當前時間分鍾

        if (_minute != 0) _hour += 1;
        offset = _hour / 2;
        if (offset >= 12) offset = 0;
        //zhiHour = zhiStr[offset].ToString();

        //計算天幹
        int ts = Utils.daysBetween(_date, Consts.GanZhiStartDay);
        i = ts % 60;

        indexGan = ((i % 10 + 1) * 2 - 1) % 10 - 1; //ganStr[i % 10] 為日的天幹,(n*2-1) %10得出地支對應,n從1開始
        tmpGan = Consts.ganStr.substring(indexGan) + Consts.ganStr.substring(0, indexGan + 2);//湊齊12位
        //ganHour = ganStr[((i % 10 + 1) * 2 - 1) % 10 - 1].ToString();

        return tmpGan.toCharArray()[offset] + "" + Consts.zhiStr.toCharArray()[offset];

    }
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:29,代碼來源:CalcLunar.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: initSimulatorName

import java.util.Date; //導入方法依賴的package包/類
private void initSimulatorName(){
	Date d = new Date();
	ParameterizedPaySim.simulatorName = "PS_" + (d.getYear() + 1900) + (d.getMonth() + 1)  + d.getDate() + d.getHours() + d.getMinutes()
			+ d.getSeconds() + "_" + this.seed;
	//System.out.println(simulatorName + "\n");
	File f = new File(System.getProperty("user.dir")  +"//outputs//" + ParameterizedPaySim.simulatorName);
	f.mkdir();
}
 
開發者ID:EdgarLopezPhD,項目名稱:PaySim,代碼行數:9,代碼來源:ParameterizedPaySim.java

示例9: isXianXing

import java.util.Date; //導入方法依賴的package包/類
public static boolean isXianXing() {
    boolean limit = false;
    Date date = new Date(System.currentTimeMillis());
    final Calendar ca = Calendar.getInstance();
    ca.setTime(date);
    int w = ca.get(Calendar.DAY_OF_WEEK) - 1;
    if (w == LIMIT && date.getHours() >= 7 && date.getHours() < 20) limit = true;
    return limit;
}
 
開發者ID:8luerain,項目名稱:AutoCar,代碼行數:10,代碼來源:DateUtils.java

示例10: isBusyTime

import java.util.Date; //導入方法依賴的package包/類
public static boolean isBusyTime() {
    boolean limit = false;
    Date date = new Date(System.currentTimeMillis());
    final Calendar ca = Calendar.getInstance();
    ca.setTime(date);
    int w = ca.get(Calendar.DAY_OF_WEEK) - 1;
    if (w >= 1 && w <= 5) {//周一到周五
        if ((date.getHours() >= 7 && date.getHours() < 9) ||
                (date.getHours() >= 17 && date.getHours() < 20)) limit = true;
    }

    return limit;
}
 
開發者ID:8luerain,項目名稱:AutoCar,代碼行數:14,代碼來源:DateUtils.java

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

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

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

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

示例15:

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


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