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


Java Years.getYears方法代碼示例

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


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

示例1: exec

import org.joda.time.Years; //導入方法依賴的package包/類
@Override
public Long exec(Tuple input) throws IOException
{
    if (input == null || input.size() < 2) {
        return null;
    }

    DateTime startDate = (DateTime) input.get(0);
    DateTime endDate = (DateTime) input.get(1);

    // Larger value first
    Years y = Years.yearsBetween(endDate, startDate);
    // joda limitation, only integer range, at the risk of overflow, need to be improved
    return (long) y.getYears();

}
 
開發者ID:sigmoidanalytics,項目名稱:spork-streaming,代碼行數:17,代碼來源:YearsBetween.java

示例2: exec

import org.joda.time.Years; //導入方法依賴的package包/類
@Override
public Long exec(Tuple input) throws IOException
{
    if (input == null || input.size() < 2 || input.get(0) == null || input.get(1) == null) {
        return null;
    }

    DateTime startDate = (DateTime) input.get(0);
    DateTime endDate = (DateTime) input.get(1);

    // Larger value first
    Years y = Years.yearsBetween(endDate, startDate);
    // joda limitation, only integer range, at the risk of overflow, need to be improved
    return (long) y.getYears();

}
 
開發者ID:sigmoidanalytics,項目名稱:spork,代碼行數:17,代碼來源:YearsBetween.java

示例3: getDeltaSinceEpoch

import org.joda.time.Years; //導入方法依賴的package包/類
public static int getDeltaSinceEpoch(int time, int tempRes) {
    int delta = 0;
    
    // Epoch
    MutableDateTime epoch = new MutableDateTime();
    epoch.setDate(0);
    
    DateTime dt = new DateTime(time*1000, DateTimeZone.UTC);
    
    switch(tempRes) {
    case FrameworkUtils.HOUR:
        Hours hours = Hours.hoursBetween(epoch, dt);
        delta = hours.getHours();
        break;
    case FrameworkUtils.DAY:
        Days days = Days.daysBetween(epoch, dt);
        delta = days.getDays();
        break;
    case FrameworkUtils.WEEK:
        Weeks weeks = Weeks.weeksBetween(epoch, dt);
        delta = weeks.getWeeks();
        break;
    case FrameworkUtils.MONTH:
        Months months = Months.monthsBetween(epoch, dt);
        delta = months.getMonths();
        break;
    case FrameworkUtils.YEAR:
        Years years = Years.yearsBetween(epoch, dt);
        delta = years.getYears();
        break;
    default:
        hours = Hours.hoursBetween(epoch, dt);
        delta = hours.getHours();
        break;
    }
    
    return delta;
}
 
開發者ID:ViDA-NYU,項目名稱:data-polygamy,代碼行數:39,代碼來源:FrameworkUtils.java

示例4: getLengthOfService

import org.joda.time.Years; //導入方法依賴的package包/類
public int getLengthOfService(Employee employee, LocalDate refDate) throws AxelorException{
	
	try{
		Years years = Years.yearsBetween(employee.getSeniorityDate(), refDate == null ? Beans.get(GeneralService.class).getTodayDate() : refDate );
		return years.getYears();
	}catch (IllegalArgumentException e){
		throw new AxelorException(String.format( I18n.get( IExceptionMessage.EMPLOYEE_NO_SENIORITY_DATE ), employee.getName() ), IException.NO_VALUE);
	}
	
}
 
開發者ID:axelor,項目名稱:axelor-business-suite,代碼行數:11,代碼來源:EmployeeServiceImpl.java

示例5: getAge

import org.joda.time.Years; //導入方法依賴的package包/類
public int getAge(Employee employee, LocalDate refDate) throws AxelorException{
	
	try{
		Years years = Years.yearsBetween(employee.getBirthDate(), refDate == null ? Beans.get(GeneralService.class).getTodayDate() : refDate );
		return years.getYears();
	}catch (IllegalArgumentException e){
		throw new AxelorException(String.format( I18n.get( IExceptionMessage.EMPLOYEE_NO_BIRTH_DATE ), employee.getName() ), IException.NO_VALUE);
	}
}
 
開發者ID:axelor,項目名稱:axelor-business-suite,代碼行數:10,代碼來源:EmployeeServiceImpl.java

示例6: getAge

import org.joda.time.Years; //導入方法依賴的package包/類
/**
 * Calculates the age of the person between the given birthDate and the toDate
 *
 * @param fromDate
 * @param toDate
 * @return
 */
public static int getAge(Date fromDate, Date toDate) {
  if (fromDate == null || toDate == null) {
    return 0;
  }

  DateTime bd = new DateTime(fromDate).withTimeAtStartOfDay();
  DateTime now = new DateTime(toDate).withTimeAtStartOfDay();
  Years age = Years.yearsBetween(bd, now);
  return age.getYears();
}
 
開發者ID:thnaeff,項目名稱:GedcomStore,代碼行數:18,代碼來源:GedcomHelper.java

示例7: getAge

import org.joda.time.Years; //導入方法依賴的package包/類
public int getAge() {
    Years years = Years.yearsBetween(dateOfBirth, new DateTime());
    return years.getYears();
}
 
開發者ID:jazdw,項目名稱:rql-parser,代碼行數:5,代碼來源:Person.java

示例8: toNonNullString

import org.joda.time.Years; //導入方法依賴的package包/類
@Override
public String toNonNullString(Years value) {
    return "" + value.getYears();
}
 
開發者ID:JadiraOrg,項目名稱:jadira,代碼行數:5,代碼來源:IntegerColumnYearsMapper.java

示例9: toNonNullValue

import org.joda.time.Years; //導入方法依賴的package包/類
@Override
public Integer toNonNullValue(Years value) {
    return value.getYears();
}
 
開發者ID:JadiraOrg,項目名稱:jadira,代碼行數:5,代碼來源:IntegerColumnYearsMapper.java

示例10: years_between_two_dates_in_java_with_joda

import org.joda.time.Years; //導入方法依賴的package包/類
@Test
public void years_between_two_dates_in_java_with_joda () {
	
	DateTime start = new DateTime(2004, 12, 25, 0, 0, 0, 0);
	DateTime end = new DateTime(2006, 1, 1, 0, 0, 0, 0);
	
	Years years = Years.yearsBetween(start, end);
	
	int numberOfYears = years.getYears();
	
	assertEquals(1, numberOfYears);
}
 
開發者ID:wq19880601,項目名稱:java-util-examples,代碼行數:13,代碼來源:YearsBetweenDates.java


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