本文整理汇总了Java中org.joda.time.Days.daysBetween方法的典型用法代码示例。如果您正苦于以下问题:Java Days.daysBetween方法的具体用法?Java Days.daysBetween怎么用?Java Days.daysBetween使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.Days
的用法示例。
在下文中一共展示了Days.daysBetween方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exec
import org.joda.time.Days; //导入方法依赖的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 date first
Days d = Days.daysBetween(endDate, startDate);
long days = d.getDays();
return days;
}
示例2: getDiferencaEntreDatasEmDias
import org.joda.time.Days; //导入方法依赖的package包/类
public static int getDiferencaEntreDatasEmDias(Date date1, Date date2) {
int dias = 0;
DateTimeZone BRAZIL = DateTimeZone.forID("America/Sao_Paulo");
DateTime start = new LocalDate(date1.getTime(), BRAZIL).toDateTimeAtStartOfDay();
DateTime end = new LocalDate(date2.getTime(), BRAZIL).toDateTimeAtStartOfDay();
Days days = Days.daysBetween(start, end);
if(days.isGreaterThan(null)) {
dias = days.getDays();
} else {
days = days.negated();
if(days.isGreaterThan(null)) {
dias = days.getDays();
}
}
return dias;
}
示例3: getDiasAtrasoEncaminahmento
import org.joda.time.Days; //导入方法依赖的package包/类
public static int getDiasAtrasoEncaminahmento(TbEncaminhamento encaminhamento) {
int diasEmAtraso = 0;
if(StatusEncaminhamentoEnum.ENCAMINHADA.getId().equals(encaminhamento.getStEncaminhamento())) {
Date dataLimiteParaResponder = getDataLimiteAtendimentoUnidade(encaminhamento);
DateTimeZone BRAZIL = DateTimeZone.forID("America/Sao_Paulo");
DateTime start = new LocalDate(dataLimiteParaResponder.getTime(), BRAZIL).toDateTimeAtStartOfDay();
DateTime end = new LocalDate(new Date().getTime(), BRAZIL).toDateTimeAtStartOfDay();
Days days = Days.daysBetween(start, end);
if(days.isGreaterThan(null)) {
diasEmAtraso = days.getDays();
}
}
return diasEmAtraso;
}
示例4: difference_between_two_dates_joda
import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void difference_between_two_dates_joda () {
DateTime sinceGraduation = new DateTime(1984, 6, 4, 0, 0, GregorianChronology.getInstance());
DateTime currentDate = new DateTime(); //current date
Days diffInDays = Days.daysBetween(sinceGraduation, currentDate);
Hours diffInHours = Hours.hoursBetween(sinceGraduation, currentDate);
Minutes diffInMinutes = Minutes.minutesBetween(sinceGraduation, currentDate);
Seconds seconds = Seconds.secondsBetween(sinceGraduation, currentDate);
logger.info(diffInDays.getDays());
logger.info(diffInHours.getHours());
logger.info(diffInMinutes.getMinutes());
logger.info(seconds.getSeconds());
assertTrue(diffInDays.getDays() >= 10697);
assertTrue(diffInHours.getHours() >= 256747);
assertTrue(diffInMinutes.getMinutes() >= 15404876);
assertTrue(seconds.getSeconds() >= 924292577);
}
示例5: exec
import org.joda.time.Days; //导入方法依赖的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 date first
Days d = Days.daysBetween(endDate, startDate);
long days = d.getDays();
return days;
}
示例6: BackupAccessService
import org.joda.time.Days; //导入方法依赖的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: handleWarning
import org.joda.time.Days; //导入方法依赖的package包/类
/**
* Handle an account state warning produced by ldaptive account state machinery.
* <p>
* Override this method to provide custom warning message handling.
*
* @param warning the account state warning messages.
* @param response Ldaptive authentication response.
* @param configuration Password policy configuration.
* @param messages Container for messages produced by account state warning handling.
*/
protected void handleWarning(
final AccountState.Warning warning,
final AuthenticationResponse response,
final LdapPasswordPolicyConfiguration configuration,
final List<MessageDescriptor> messages) {
logger.debug("Handling warning {}", warning);
if (warning == null) {
logger.debug("Account state warning not defined");
return;
}
final Calendar expDate = warning.getExpiration();
final Days ttl = Days.daysBetween(Instant.now(), new Instant(expDate));
logger.debug(
"Password expires in {} days. Expiration warning threshold is {} days.",
ttl.getDays(),
configuration.getPasswordWarningNumberOfDays());
if (configuration.isAlwaysDisplayPasswordExpirationWarning()
|| ttl.getDays() < configuration.getPasswordWarningNumberOfDays()) {
messages.add(new PasswordExpiringWarningMessageDescriptor(
"Password expires in {0} days. Please change your password at <href=\"{1}\">{1}</a>",
ttl.getDays(),
configuration.getPasswordPolicyUrl()));
}
if (warning.getLoginsRemaining() > 0) {
messages.add(new DefaultMessageDescriptor(
"password.expiration.loginsRemaining",
"You have {0} logins remaining before you MUST change your password.",
warning.getLoginsRemaining()));
}
}
示例8: handleWarning
import org.joda.time.Days; //导入方法依赖的package包/类
/**
* Handle an account state warning produced by ldaptive account state machinery.
* <p>
* Override this method to provide custom warning message handling.
*
* @param error Account state warning.
* @param response Ldaptive authentication response.
* @param configuration Password policy configuration.
* @param messages Container for messages produced by account state warning handling.
*/
protected void handleWarning(
final AccountState.Warning warning,
final AuthenticationResponse response,
final LdapPasswordPolicyConfiguration configuration,
final List<Message> messages) {
if (warning == null) {
logger.debug("Account state warning not defined");
return;
}
final Calendar expDate = warning.getExpiration();
final Days ttl = Days.daysBetween(Instant.now(), new Instant(expDate));
logger.debug(
"Password expires in {} days. Expiration warning threshold is {} days.",
ttl.getDays(),
configuration.getPasswordWarningNumberOfDays());
if (configuration.isAlwaysDisplayPasswordExpirationWarning()
|| ttl.getDays() < configuration.getPasswordWarningNumberOfDays()) {
messages.add(new PasswordExpiringWarningMessage(
"Password expires in {0} days. Please change your password at <href=\"{1}\">{1}</a>",
ttl.getDays(),
configuration.getPasswordPolicyUrl()));
}
if (warning.getLoginsRemaining() > 0) {
messages.add(new Message(
"password.expiration.loginsRemaining",
"You have {0} logins remaining before you MUST change your password.",
warning.getLoginsRemaining()));
}
}
示例9: onCreate
import org.joda.time.Days; //导入方法依赖的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.Days; //导入方法依赖的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: diasAtrasoAoManifestante
import org.joda.time.Days; //导入方法依赖的package包/类
public int diasAtrasoAoManifestante(TbManifestacao manifestation) {
int diasEmAtraso = 0;
if (manifestation != null
&& !StatusManifestacaoEnum.SOLUCIONADA.getId().equals(manifestation.getStStatusManifestacao())) {
if(securityService.isInterlocutor() || securityService.isOperador()) {
Date dateLimitToAnswer = getPrazoAtendimento(manifestation);
DateTimeZone BRAZIL = DateTimeZone.forID("America/Sao_Paulo");
DateTime start = new LocalDate(dateLimitToAnswer.getTime(), BRAZIL).toDateTimeAtStartOfDay();
DateTime end = new LocalDate(new Date().getTime(), BRAZIL).toDateTimeAtStartOfDay();
Days days = Days.daysBetween(start, end);
if(days.isGreaterThan(null)) {
diasEmAtraso = days.getDays();
}
} else {
Integer prazoEncaminhamento = manifestation.getIdTipoManifestacao().getPrazoEntrada();
Integer prazoRespostaAOuvidoria = manifestation.getIdTipoManifestacao().getPrazoAreaSolucionadora();
Integer prazoRespostaAoManifestante = manifestation.getIdTipoManifestacao().getPrazoRespostaCidadao();
int diasParaResponderManifestante = prazoEncaminhamento + prazoRespostaAoManifestante + prazoRespostaAOuvidoria;
Date dataManifestacao = manifestation.getDtCadastro();
Date dataAtual = new Date();
int diasTranscorridos = DataHelper.getDiferencaEntreDatasEmDias(dataAtual, dataManifestacao);
if (diasTranscorridos > ++diasParaResponderManifestante) {
diasEmAtraso = diasTranscorridos - diasParaResponderManifestante;
}
}
}
return diasEmAtraso;
}
示例12: recuperaDiasAtrasoAoManifestante
import org.joda.time.Days; //导入方法依赖的package包/类
private void recuperaDiasAtrasoAoManifestante(DTOManifestacao dtoManifestacao) {
int diasEmAtraso = 0;
if (dtoManifestacao != null
&& !StatusManifestacaoEnum.SOLUCIONADA.getId().equals(dtoManifestacao.getIdStatusManifestacao())) {
if(securityService.isInterlocutor() || securityService.isOperador()) {
Date dateLimitToAnswer = dtoManifestacao.getPrazoAtendimento();
DateTimeZone BRAZIL = DateTimeZone.forID("America/Sao_Paulo");
DateTime start = new LocalDate(dateLimitToAnswer.getTime(), BRAZIL).toDateTimeAtStartOfDay();
DateTime end = new LocalDate(new Date().getTime(), BRAZIL).toDateTimeAtStartOfDay();
Days days = Days.daysBetween(start, end);
if(days.isGreaterThan(null)) {
diasEmAtraso = days.getDays();
}
} else {
Integer prazoEncaminhamento = dtoManifestacao.getPrazoEncaminhamento();
Integer prazoRespostaAOuvidoria = dtoManifestacao.getPrazoRespostaAOuvidoria();
Integer prazoRespostaAoManifestante = dtoManifestacao.getPrazoRespostaAoManifestante();
int diasParaResponderManifestante = prazoEncaminhamento + prazoRespostaAoManifestante + prazoRespostaAOuvidoria;
Date dataManifestacao = dtoManifestacao.getDataCadastro();
Date dataAtual = new Date();
int diasTranscorridos = DataHelper.getDiferencaEntreDatasEmDias(dataAtual, dataManifestacao);
if (diasTranscorridos > ++diasParaResponderManifestante) {
diasEmAtraso = diasTranscorridos - diasParaResponderManifestante;
}
}
}
dtoManifestacao.setDiasAtraso(diasEmAtraso);
// return diasEmAtraso;
}
示例13: getDiasNacimiento_Hoy
import org.joda.time.Days; //导入方法依赖的package包/类
/**
* Obtiene la cantidad de dias entre la fecha de nacimiento y la fecha actual
* @param LocalDate fechadeNacimiento
* @return org.joda.time.Days meses
*/
@Override
@Programmatic
public int getDiasNacimiento_Hoy(LocalDate fechadeNacimiento) {
// TODO Auto-generated method stub
Days meses = Days.daysBetween(fechadeNacimiento, fecha_actual);
return meses.getDays();
}
示例14: getDiasNacimiento_Hoy
import org.joda.time.Days; //导入方法依赖的package包/类
/**
* Obtiene la cantidad de dias entre la fecha de nacimiento y la fecha actual
* @param fechadeNacimiento LocalDate
* @return org.joda.time.Days meses
*/
@Override
@Programmatic
public int getDiasNacimiento_Hoy(LocalDate fechadeNacimiento) {
// TODO Auto-generated method stub
Days meses = Days.daysBetween(fechadeNacimiento, fecha_actual);
return meses.getDays();
}
示例15: days_between_two_dates_in_java_with_joda
import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void days_between_two_dates_in_java_with_joda () {
// start day is 1 day in the past
DateTime startDate = new DateTime().minusDays(1);
DateTime endDate = new DateTime();
Days d = Days.daysBetween(startDate, endDate);
int days = d.getDays();
assertEquals(1, days);
}