本文整理汇总了Java中org.joda.time.Days.getDays方法的典型用法代码示例。如果您正苦于以下问题:Java Days.getDays方法的具体用法?Java Days.getDays怎么用?Java Days.getDays使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.Days
的用法示例。
在下文中一共展示了Days.getDays方法的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: 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;
}
示例5: 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()));
}
}
示例6: 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()));
}
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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();
}
示例11: 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();
}
示例12: 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);
}
示例13: getIntervaloDias
import org.joda.time.Days; //导入方法依赖的package包/类
private static int getIntervaloDias(Date dataInicio, Date dataFim) {
LocalDate dayInicio = LocalDate.fromDateFields(dataInicio);
LocalDate dayFim = LocalDate.fromDateFields(dataFim);
Days between = Days.daysBetween(dayInicio, dayFim);
return between.getDays();
}
示例14: getPrevDates
import org.joda.time.Days; //导入方法依赖的package包/类
/**
* Gets run dates previous to a specific date within a window
* of days from that date.
*
* @param log_date the run date
* @param window the number of days previous to the current date
* @return the list of previous run dates
* @throws SQLException if there is an error retrieving the previous
* run dates
*/
public ArrayList<Date> getPrevDates(Date log_date, int window) throws SQLException{
ArrayList<Date> prevDates = new ArrayList<Date>();
if(prevDateBufDate != null && prevDateBuf != null && prevDateBufDate.equals(log_date)
&& prevDateBufWindow >= window){
//pull the dates within the day window from the prevDateBuf cache
Date pd = null;
int windowcount = 0;
for(Date d : prevDateBuf){
if(windowcount >= window){
break;
}
if(pd == null){
pd = d;
windowcount++;
} else {
DateTime morerecent = new DateTime(d.getTime());
DateTime lessrecent = new DateTime(pd.getTime());
Days days = Days.daysBetween(morerecent, lessrecent);
windowcount += days.getDays();
pd = d;
}
prevDates.add(d);
}
} else {
String domainsprefix = properties.getProperty(DOMAINSPREFIXKEY);
String resipsprefix = properties.getProperty(RESIPSPREFIXKEY);
ArrayList<String> tablenames = new ArrayList<String>();
ResultSet rs1 = null;
try{
rs1 = dbi.executeQueryWithResult(properties
.getProperty(TABLES_QUERY1KEY));
while (rs1.next()) {
tablenames.add(rs1.getString(1));
}
} catch(Exception e){
if(log.isErrorEnabled()){
log.error(e);
}
} finally {
if(rs1 != null && !rs1.isClosed()){
rs1.close();
}
}
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(log_date);
for (int i = 0; i < window; i++) {
cal.roll(Calendar.DAY_OF_YEAR, false);
Date temp = cal.getTime();
String datestr = df.format(temp);
if (tablenames.contains(domainsprefix + "_" + datestr)
&& tablenames.contains(resipsprefix + "_" + datestr)) {
prevDates.add(temp);
}
}
//cache the values for later
if(prevDateBuf == null){
prevDateBuf = new ArrayList<Date>();
} else {
prevDateBuf.clear();
}
prevDateBuf.addAll(prevDates);
prevDateBufDate = log_date;
prevDateBufWindow = window;
}
return prevDates;
}
示例15: execute
import org.joda.time.Days; //导入方法依赖的package包/类
@Override
public void execute(Environment env, Map params, TemplateModel[] loopVars,
TemplateDirectiveBody body)
throws TemplateException, IOException {
// 检查是否传递参数,此指令禁止传参!
if (params.isEmpty()) {
throw new TemplateModelException(
"This directive doesn't allow parameters.");
}
// 禁用循环变量
/*
* 循环变量
用户定义指令可以有循环变量,通常用于重复嵌套内容,基本用法是:作为nested指令的参数传递循环变量的实际值,而在调用用户定义指令时,在${"<@…>"}开始标记的参数后面指定循环变量的名字
例子:
<#macro repeat count>
<#list 1..count as x>
<#nested x, x/2, x==count>
</#list>
</#macro>
<@repeat count=4 ; c, halfc, last>
${c}. ${halfc}<#if last> Last!</#if>
</@repeat>
*/
if (loopVars.length != 0) {
throw new TemplateModelException(
"This directive doesn't allow loop variables.");
}
// 指令内容体没有任何内容的
if (body == null) {
SimpleScalar timeScalar = (SimpleScalar) params.get("time");
String time = timeScalar.getAsString();
String ftime = StringUtils.EMPTY;
if (!Strings.isNullOrEmpty(time)) {
final DateTime p_date = DateTime.parse(time, DateFormatter.DTP_YYYY_MM_DD_HH_MM_SS);
final DateTime today = DateTime.now();
Days d = Days.daysBetween(p_date, today);
int days = d.getDays();
if (days == 0) {
int hour = (int) ((today.getMillis() - p_date.getMillis()) / 3600000);
if (hour == 0) {
ftime = Math.max((today.getMillis() - p_date.getMillis()) / 60000, 1) + "分钟前";
} else {
ftime = hour + "小时前";
}
} else if (days == 1) {
ftime = "昨天";
} else if (days == 2) {
ftime = "前天";
} else if (days > 2 && days <= 10) {
ftime = days + "天前";
} else {
ftime = p_date.toString(DateFormatter.YYYY_MM_DD);
}
}
Writer out = env.getOut();
out.write(ftime);
} else {
throw new RuntimeException("missing body");
}
}