本文整理汇总了Java中org.joda.time.Months.monthsBetween方法的典型用法代码示例。如果您正苦于以下问题:Java Months.monthsBetween方法的具体用法?Java Months.monthsBetween怎么用?Java Months.monthsBetween使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.Months
的用法示例。
在下文中一共展示了Months.monthsBetween方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: storeAllMeasures
import org.joda.time.Months; //导入方法依赖的package包/类
/**
* Obtain the indicators from the statistics and stores them into the im
*
* @param im indicatorMap to store the indicators
* @param statistics statistics of the git.
*/
private void storeAllMeasures(IndicatorsMap im, GitLogStatistics statistics)
{
DateTime dt = new DateTime(statistics.firstCommitDate);
Months months = Months.monthsBetween(dt, new DateTime());
Weeks weeks = Weeks.weeksBetween(dt, new DateTime());
im.add("git average-commits-per-month", (double) statistics.totalCommits / months.getMonths());
im.add("git average-commits-per-week", (double) statistics.totalCommits / weeks.getWeeks());
im.add("git average-commits-per-committer", (double) statistics.totalCommits / statistics.totalCommitters);
im.add("git average-files-changed-per-committer", (double) statistics.totalFilesChanged
/ statistics.totalCommitters);
im.add("git average-lines-added-per-commmit", (double) statistics.totalLinesAdded / statistics.totalCommits);
im.add("git average-lines-removed-per-commit", (double) statistics.totalLinesRemoved / statistics.totalCommits);
im.add("git average-files-changed-per-commit", (double) statistics.totalFilesChanged / statistics.totalCommits);
im.add("git distribution-commits-by-hour", RiskDataType.DISTRIBUTION,
getDistribution(statistics.commitsByHour, statistics.totalCommits));
im.add("git distribution-commits-by-weekday", RiskDataType.DISTRIBUTION,
getDistribution(statistics.commitsByWeekday, statistics.totalCommits));
}
示例4: 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();
}
示例5: 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;
}
示例6: BackupAccessService
import org.joda.time.Months; //导入方法依赖的package包/类
@Autowired
public BackupAccessService(DataConfigService config, BackupFileService service) {
this.config = config;
this.fileService = service;
// timed backups
monthlyBackup = new ConditionalBackupExecutor("monthly", 6, (now, last) -> {
final Months duration = Months.monthsBetween(last, now);
return duration.getMonths() >= 1;
}
);
daylyBackup = new ConditionalBackupExecutor("dayly", 7, (now, last) -> {
final Days duration = Days.daysBetween(last, now);
return duration.getDays() >= 1;
}
);
hourlyBackup = new ConditionalBackupExecutor("hourly", 24, (now, last) -> {
final Hours duration = Hours.hoursBetween(last, now);
return duration.getHours() >= 1;
}
);
// triggered backups
triggeredBackup = new BackupExecutor("triggered", 100);
}
示例7: 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;
}
示例8: 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;
}
示例9: onCreate
import org.joda.time.Months; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_knell);
ButterKnife.bind(this);
Birthday birthday = getBirthdayManager().get();
DateTime birDateTime = new DateTime(birthday.year, birthday.month, birthday.day, 0, 0);
Days days = Days.daysBetween(birDateTime, DateTime.now());
Hours hours = Hours.hoursBetween(birDateTime, DateTime.now());
Minutes minutes = Minutes.minutesBetween(birDateTime, DateTime.now());
Weeks weeks = Weeks.weeksBetween(birDateTime, DateTime.now());
Years years = Years.yearsBetween(birDateTime, DateTime.now());
Months months = Months.monthsBetween(birDateTime, DateTime.now());
Timber.d("onCreate: 年:%d", years.getYears());
Timber.d("onCreate: 月:%d", months.getMonths());
Timber.d("onCreate: 周:%d", weeks.getWeeks());
Timber.d("onCreate: 天数为:%d", days.getDays());
Timber.d("onCreate: 小时数为:%d", hours.getHours());
Timber.d("onCreate: 分钟数为:%d", minutes.getMinutes());
tvYear.setText(String.valueOf(years.getYears()));
tvMonth.setText(String.valueOf(months.getMonths()));
tvWeek.setText(String.valueOf(weeks.getWeeks()));
tvDay.setText(String.valueOf(days.getDays()));
tvHour.setText(String.valueOf(hours.getHours()));
tvMinute.setText(String.valueOf(minutes.getMinutes()));
}
示例10: 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;
}
示例11: 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());
}
示例12: 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();
}
示例13: 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);
}