org.joda.time.Partial.get()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.joda.time.Partial.get()方法的一些代码示例,展示了Partial.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Partial.get()方法的具体详情如下:
包路径:org.joda.time.Partial
类名称:Partial
方法名:get

Partial.get介绍

[英]Gets the chronology of the partial which is never null.

The Chronology is the calculation engine behind the partial and provides conversion and validation of the fields in a particular calendar system.
[中]获取从不为空的分部的时间顺序。
年表是部分日历背后的计算引擎,提供特定日历系统中字段的转换和验证。

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

public static boolean isCompatible(Partial p1, Partial p2) {
 if (p1 == null) return true;
 if (p2 == null) return true;
 for (int i = 0; i < p1.size(); i++) {
  DateTimeFieldType type = p1.getFieldType(i);
  int v = p1.getValue(i);
  if (JodaTimeUtils.hasField(p2,type)) {
   if (v != p2.get(type)) {
    return false;
   }
  }
 }
 return true;
}
// Uses p2 to resolve dow for p1

代码示例来源:origin: stanfordnlp/CoreNLP

public static Partial discardMoreSpecificFields(Partial p, DateTimeFieldType d)
{
 Partial res = new Partial();
 for (int i = 0; i < p.size(); i++) {
  DateTimeFieldType fieldType = p.getFieldType(i);
  if (fieldType.equals(d) || isMoreGeneral(fieldType, d, p.getChronology())) {
   res = res.with(fieldType, p.getValue(i));
  }
 }
 if (res.isSupported(JodaTimeUtils.DecadeOfCentury) && !res.isSupported(DateTimeFieldType.centuryOfEra())) {
  if (p.isSupported(DateTimeFieldType.year())) {
   res = res.with(DateTimeFieldType.centuryOfEra(), p.get(DateTimeFieldType.year()) / 100);
  }
 }
 return res;
}

代码示例来源:origin: stanfordnlp/CoreNLP

public static Instant getInstant(Partial p, ZoneId timezone)
{
 if (p == null) return null;
 int year = p.isSupported(DateTimeFieldType.year())? p.get(DateTimeFieldType.year()):0;
 if (!p.isSupported(DateTimeFieldType.year())) {
  if (p.isSupported(DateTimeFieldType.centuryOfEra())) {
   year += 100*p.get(DateTimeFieldType.centuryOfEra());
  }
  if (p.isSupported(DateTimeFieldType.yearOfCentury())) {
   year += p.get(DateTimeFieldType.yearOfCentury());
  } else if (p.isSupported(DecadeOfCentury)) {
   year += 10*p.get(DecadeOfCentury);
  }
 }
 int moy = p.isSupported(DateTimeFieldType.monthOfYear())? p.get(DateTimeFieldType.monthOfYear()):1;
 if (!p.isSupported(DateTimeFieldType.monthOfYear())) {
  if (p.isSupported(QuarterOfYear)) {
   moy += 3*(p.get(QuarterOfYear)-1);
  }
 }
 int dom = p.isSupported(DateTimeFieldType.dayOfMonth())? p.get(DateTimeFieldType.dayOfMonth()):1;
 int hod = p.isSupported(DateTimeFieldType.hourOfDay())? p.get(DateTimeFieldType.hourOfDay()):0;
 int moh = p.isSupported(DateTimeFieldType.minuteOfHour())? p.get(DateTimeFieldType.minuteOfHour()):0;
 int som = p.isSupported(DateTimeFieldType.secondOfMinute())? p.get(DateTimeFieldType.secondOfMinute()):0;
 int msos = p.isSupported(DateTimeFieldType.millisOfSecond())? p.get(DateTimeFieldType.millisOfSecond()):0;
 return new DateTime(year, moy, dom, hod, moh, som, msos, fromTimezone(timezone)).toInstant();
}

代码示例来源:origin: fenix-framework/fenix-framework

public static JsonElement getJsonFor(Partial value) {
  if (value == null) {
    return JsonNull.INSTANCE;
  }
  JsonObject json = new JsonObject();
  for (DateTimeField field : value.getFields()) {
    json.addProperty(field.getName(), value.get(field.getType()));
  }
  return json;
}

代码示例来源:origin: stanfordnlp/CoreNLP

if (p.isSupported(DateTimeFieldType.yearOfCentury())) {
 if (!p.isSupported(DateTimeFieldType.centuryOfEra())) {
  int yoc = p.get(DateTimeFieldType.yearOfCentury());
  int refYear = p2.getValue(i);
  int century = refYear / 100;
} else if (p.isSupported(JodaTimeUtils.DecadeOfCentury)) {
 if (!p.isSupported(DateTimeFieldType.centuryOfEra())) {
  int decade = p.get(JodaTimeUtils.DecadeOfCentury);
  int refYear = p2.getValue(i);
  int century = refYear / 100;
int year = p.get(DateTimeFieldType.yearOfCentury()) + p.get(DateTimeFieldType.centuryOfEra())*100;
p = p.with(DateTimeFieldType.year(), year);
p = p.without(DateTimeFieldType.yearOfCentury());

代码示例来源:origin: stanfordnlp/CoreNLP

if (p.isSupported(DateTimeFieldType.yearOfCentury())) {
  if (!p.isSupported(DateTimeFieldType.centuryOfEra())) {
   int yoc = p.get(DateTimeFieldType.yearOfCentury());
   int refYear = p2.getValue(i);
   int century = refYear / 100;
 int year = p.get(DateTimeFieldType.yearOfCentury()) + p.get(DateTimeFieldType.centuryOfEra())*100;
 p = p.with(DateTimeFieldType.year(), year);
 p = p.without(DateTimeFieldType.yearOfCentury());
int hour = -1;
if (p.isSupported(DateTimeFieldType.hourOfHalfday())) {
 hour = p.get(DateTimeFieldType.hourOfHalfday());
 p = p.without(DateTimeFieldType.hourOfHalfday());
} else if (p.isSupported(DateTimeFieldType.clockhourOfHalfday())) {
 hour = p.get(DateTimeFieldType.clockhourOfHalfday())-1;
 p = p.without(DateTimeFieldType.clockhourOfHalfday());
} else if (p.isSupported(DateTimeFieldType.clockhourOfDay())) {
 hour = p.get(DateTimeFieldType.clockhourOfDay())-1;
 p = p.without(DateTimeFieldType.clockhourOfDay());
} else if (p.isSupported(DateTimeFieldType.hourOfDay())) {
 hour = p.get(DateTimeFieldType.hourOfDay());
 p = p.without(DateTimeFieldType.hourOfDay());
 if (p.get(DateTimeFieldType.halfdayOfDay()) == SUTime.HALFDAY_PM) {
  if (hour < 12) {
   hour = hour+12;

代码示例来源:origin: stanfordnlp/CoreNLP

public List<Temporal> toList() {
 if (JodaTimeUtils.hasField(base, DateTimeFieldType.year())
   && JodaTimeUtils.hasField(base, DateTimeFieldType.monthOfYear())
   && JodaTimeUtils.hasField(base, DateTimeFieldType.dayOfWeek())) {
  List<Temporal> list = new ArrayList<>();
  Partial pt = new Partial();
  pt = JodaTimeUtils.setField(pt, DateTimeFieldType.year(), base.get(DateTimeFieldType.year()));
  pt = JodaTimeUtils.setField(pt, DateTimeFieldType.monthOfYear(), base.get(DateTimeFieldType.monthOfYear()));
  pt = JodaTimeUtils.setField(pt, DateTimeFieldType.dayOfMonth(), 1);
  Partial candidate = JodaTimeUtils.resolveDowToDay(base, pt);
  if (candidate.get(DateTimeFieldType.monthOfYear()) != base.get(DateTimeFieldType.monthOfYear())) {
   pt = JodaTimeUtils.setField(pt, DateTimeFieldType.dayOfMonth(), 8);
   candidate = JodaTimeUtils.resolveDowToDay(base, pt);
   if (candidate.get(DateTimeFieldType.monthOfYear()) != base.get(DateTimeFieldType.monthOfYear())) {
    // give up
    return null;
   }
  }
  try {
   while (candidate.get(DateTimeFieldType.monthOfYear()) == base.get(DateTimeFieldType.monthOfYear())) {
    list.add(new PartialTime(this, candidate));
    pt = JodaTimeUtils.setField(pt, DateTimeFieldType.dayOfMonth(), pt.get(DateTimeFieldType.dayOfMonth()) + 7);
    candidate = JodaTimeUtils.resolveDowToDay(base, pt);
   }
  } catch (IllegalFieldValueException ex) {}
  return list;
 } else {
  return null;
 }
}

代码示例来源:origin: stanfordnlp/CoreNLP

if (p.isSupported(JodaTimeUtils.DecadeOfCentury)) {
 if (p.isSupported(DateTimeFieldType.centuryOfEra())) {
  int year = p.get(DateTimeFieldType.centuryOfEra()) * 100 + p.get(JodaTimeUtils.DecadeOfCentury)*10;
  p = p.without(JodaTimeUtils.DecadeOfCentury);
  p = p.without(DateTimeFieldType.centuryOfEra());
  p = p.with(DateTimeFieldType.year(), year);
 } else {
  int year = p.get(JodaTimeUtils.DecadeOfCentury)*10;
  p = p.without(JodaTimeUtils.DecadeOfCentury);
  p = p.with(DateTimeFieldType.yearOfCentury(), year);
  int year = p.get(DateTimeFieldType.centuryOfEra()) * 100;
  p = p.without(DateTimeFieldType.centuryOfEra());
  p = p.with(DateTimeFieldType.year(), year);
 if (fieldType == DateTimeFieldType.monthOfYear()) {
  if (p.isSupported(QuarterOfYear)) {
   p = p.with(DateTimeFieldType.monthOfYear(), (p.get(QuarterOfYear)-1)*3+1);
   continue;
  } else if (p.isSupported(HalfYearOfYear)) {
   p = p.with(DateTimeFieldType.monthOfYear(), (p.get(HalfYearOfYear)-1)*6+1);
   continue;

代码示例来源:origin: stanfordnlp/CoreNLP

@Override
public SUTime.Time resolve(SUTime.Time t, int flags) {
 Partial p = (t != null)? t.getJodaTimePartial():null;
 if (p != null) {
  if (JodaTimeUtils.hasField(p, DateTimeFieldType.year())) {
   int year = p.get(DateTimeFieldType.year());
   SUTime.Time resolved = resolveWithYear(year);
   if (resolved != null) {
    return resolved;
   }
  }
 }
 return this;
}

代码示例来源:origin: stanfordnlp/CoreNLP

Partial p2 = p.base.withField(DateTimeFieldType.centuryOfEra(), p.base.get(DateTimeFieldType.centuryOfEra()) + unsupported.getYears() / 100);
p = new PartialTime(p, p2);
unsupported = unsupported.withYears(0);

代码示例来源:origin: stanfordnlp/CoreNLP

int era = base.get(DateTimeFieldType.era());
if (era == 0) {
 builder.appendLiteral('-');

代码示例来源:origin: fenix-framework/fenix-framework

public static String partialToString(Partial partial) {
  StringBuilder buf = new StringBuilder();
  for (int i = 0; i < DATE_TIME_FIELDS.length; i++) {
    DateTimeFieldType field = DATE_TIME_FIELDS[i];
    if (partial.isSupported(field)) {
      if (buf.length() > 0) {
        buf.append(",");
      }
      buf.append(field.getName() + "=" + partial.get(field));
    }
  }
  return buf.toString();
}

代码示例来源:origin: FenixEdu/fenixedu-academic

public DateTime getEndAsDateTime() {
  return new DateTime(new DateTime().getYear(), getPeriodEndDate().get(DateTimeFieldType.monthOfYear()),
      getPeriodEndDate().get(DateTimeFieldType.dayOfMonth()), 0, 0, 0, 0);
}

代码示例来源:origin: FenixEdu/fenixedu-academic

public DateTime getStartAsDateTime() {
  return new DateTime(new DateTime().getYear(), getPeriodStartDate().get(DateTimeFieldType.monthOfYear()),
      getPeriodStartDate().get(DateTimeFieldType.dayOfMonth()), 0, 0, 0, 0);
}

代码示例来源:origin: FenixEdu/fenixedu-academic

public int getDayLastPayment() {
  return getLastPayment().get(DateTimeFieldType.dayOfMonth());
}

代码示例来源:origin: FenixEdu/fenixedu-academic

public YearMonth(Partial date) {
  super();
  setYear(date.get(DateTimeFieldType.year()));
  setMonth(Month.values()[(date.get(DateTimeFieldType.monthOfYear()) - 1)]);
}

代码示例来源:origin: org.opencds.cqf/cql-engine

private static void addDateTime(List<Object> list, DateTime dateTime) {
  for (int i = 0; i < dateTime.getPartial().size(); ++i) {
    list.add(dateTime.getPartial().get(DateTime.getField(i)));
  }
  list.add(dateTime.getTimezoneOffset());
}

代码示例来源:origin: org.opencds.cqf/cql-engine

private static void addTime(List<Object> list, Time time) {
  for (int i = 0; i < time.getPartial().size(); ++i) {
    list.add(time.getPartial().get(Time.getField(i)));
  }
  list.add(time.getTimezoneOffset());
}

代码示例来源:origin: FenixEdu/fenixedu-academic

public ExecutionYear findByPartial(final Partial partial) {
  final Integer year = Integer.valueOf(partial.get(DateTimeFieldType.year()));
  final Set<ExecutionYear> executionYears = updateIfNeeded(year);
  if (executionYears != null) {
    for (final ExecutionYear executionYear : executionYears) {
      if (executionYear.getBeginDateYearMonthDay().getYear() == year) {
        return executionYear;
      }
    }
  }
  return null;
}

代码示例来源:origin: edu.stanford.nlp/stanford-corenlp

@Override
public SUTime.Time resolve(SUTime.Time t, int flags) {
 Partial p = (t != null)? t.getJodaTimePartial():null;
 if (p != null) {
  if (JodaTimeUtils.hasField(p, DateTimeFieldType.year())) {
   int year = p.get(DateTimeFieldType.year());
   SUTime.Time resolved = resolveWithYear(year);
   if (resolved != null) {
    return resolved;
   }
  }
 }
 return this;
}

相关文章