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


Java Months.getMonths方法代碼示例

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


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

示例1: exec

import org.joda.time.Months; //導入方法依賴的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
    Months m = Months.monthsBetween(endDate, startDate);
    // joda limitation, only integer range, at the risk of overflow, need to be improved
    return (long) m.getMonths();

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

示例2: exec

import org.joda.time.Months; //導入方法依賴的package包/類
@Override
public Long exec(Tuple input) throws IOException
{
    if (input == null || input.size() < 2) {
        return null;
    }
    
    // Set the time to default or the output is in UTC
    DateTimeZone.setDefault(DateTimeZone.UTC);

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

    // Larger value first
    Months m = Months.monthsBetween(endDate, startDate);
    long months = m.getMonths();

    return months;

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

示例3: exec

import org.joda.time.Months; //導入方法依賴的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
    Months m = Months.monthsBetween(endDate, startDate);
    // joda limitation, only integer range, at the risk of overflow, need to be improved
    return (long) m.getMonths();

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

示例4: exec

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

    if (input.get(0) == null || input.get(1) == null) {
        return null;
    }

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

    // Larger value first
    Months m = Months.monthsBetween(endDate, startDate);
    long months = m.getMonths();

    return months;

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

示例5: areContactsRecent

import org.joda.time.Months; //導入方法依賴的package包/類
public boolean areContactsRecent(final Class<? extends PartyContact> contactClass, final int daysNotUpdated) {
    final List<? extends PartyContact> partyContacts = getPartyContacts(contactClass);
    boolean isUpdated = false;
    for (final PartyContact partyContact : partyContacts) {
        if (partyContact.getLastModifiedDate() == null) {
            isUpdated = isUpdated || false;
        } else {
            final DateTime lastModifiedDate = partyContact.getLastModifiedDate();
            final DateTime now = new DateTime();
            final Months months = Months.monthsBetween(lastModifiedDate, now);
            if (months.getMonths() > daysNotUpdated) {
                isUpdated = isUpdated || false;
            } else {
                isUpdated = isUpdated || true;
            }
        }
    }
    return isUpdated;
}
 
開發者ID:FenixEdu,項目名稱:fenixedu-academic,代碼行數:20,代碼來源:Person.java

示例6: getFrequencyElseNull

import org.joda.time.Months; //導入方法依賴的package包/類
private String getFrequencyElseNull() {
    final SortedSet<InvoiceItem> items = invoice.getItems();
    if(items.isEmpty()) {
        return null;
    }
    final InvoiceItem item = items.first();
    final LocalDate startDate = item.getStartDate();
    final LocalDate endDate = item.getEndDate();
    if(startDate == null || endDate == null) {
        return null;
    }
    Months months = Months.monthsBetween(startDate, endDate.plusDays(1));
    switch (months.getMonths()) {
    case 12:
        return "YEAR";
    case 3:
        return "QUARTER";
    case 1:
        return "MONTH";
    }
    return null;
}
 
開發者ID:estatio,項目名稱:estatio,代碼行數:23,代碼來源:InvoiceAttributesVM.java

示例7: getDeltaSinceEpoch

import org.joda.time.Months; //導入方法依賴的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

示例8: setNumberOfWeeks

import org.joda.time.Months; //導入方法依賴的package包/類
public void setNumberOfWeeks(Integer numberOfWeeks) {
    this.numberOfWeeks = new BigDecimal(numberOfWeeks);
    LocalDate localDate = LocalDate.now();
    Months months = Months.monthsBetween(localDate,localDate.plusWeeks(numberOfWeeks));
    this.months = new BigDecimal(months.getMonths());
}
 
開發者ID:thiagopa,項目名稱:planyourexchange,代碼行數:7,代碼來源:ResultCalculations.java

示例9: monthsBetween

import org.joda.time.Months; //導入方法依賴的package包/類
/**
 * Calculates the number of months between the start and end-date. Note this
 * method is taking daylight saving time into account and has a performance
 * overhead.
 *
 * @param startDate the start date.
 * @param endDate   the end date.
 * @return the number of months between the start and end date.
 */
public static int monthsBetween( Date startDate, Date endDate )
{
    final Months days = Months.monthsBetween( new DateTime( startDate ), new DateTime( endDate ) );

    return days.getMonths();
}
 
開發者ID:dhis2,項目名稱:dhis2-core,代碼行數:16,代碼來源:DateUtils.java

示例10: months_between_two_dates_in_java_with_joda

import org.joda.time.Months; //導入方法依賴的package包/類
@Test
public void months_between_two_dates_in_java_with_joda () {

	DateTime start = new DateTime(2005, 1, 1, 0, 0, 0, 0);
	DateTime end = new DateTime(2006, 1, 1, 0, 0, 0, 0);

	Months months = Months.monthsBetween(start, end);
	
	int monthsInYear = months.getMonths();
	
	assertEquals(12, monthsInYear);
}
 
開發者ID:wq19880601,項目名稱:java-util-examples,代碼行數:13,代碼來源:MonthsBetweenDates.java


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