本文整理匯總了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();
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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();
}
示例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);
}