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

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

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

Partial.size介绍

[英]Gets the number of fields in this partial.
[中]获取此部分中的字段数。

代码示例

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

protected static DateTimeFieldType getMostSpecific(Partial p)
{
 if (p.size() > 0) { return p.getFieldType(p.size()-1); }
 return null;
}
protected static DurationFieldType getMostGeneral(Period p)

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

protected static DateTimeFieldType getMostGeneral(Partial p)
{
 if (p.size() > 0) { return p.getFieldType(0); }
 return null;
}
protected static DateTimeFieldType getMostSpecific(Partial p)

代码示例来源:origin: joda-time/joda-time

/**
 * Gets a string version of the partial that lists all the fields.
 * <p>
 * This method exists to provide a better debugging toString than
 * the standard toString. This method lists all the fields and their
 * values in a style similar to the collections framework.
 *
 * @return a toString format that lists all the fields
 */
public String toStringList() {
  int size = size();
  StringBuilder buf = new StringBuilder(20 * size);
  buf.append('[');
  for (int i = 0; i < size; i++) {
    if (i > 0) {
      buf.append(',').append(' ');
    }
    buf.append(iTypes[i].getName());
    buf.append('=');
    buf.append(iValues[i]);
  }
  buf.append(']');
  return buf.toString();
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Gets a string version of the partial that lists all the fields.
 * <p>
 * This method exists to provide a better debugging toString than
 * the standard toString. This method lists all the fields and their
 * values in a style similar to the collections framework.
 *
 * @return a toString format that lists all the fields
 */
public String toStringList() {
  int size = size();
  StringBuilder buf = new StringBuilder(20 * size);
  buf.append('[');
  for (int i = 0; i < size; i++) {
    if (i > 0) {
      buf.append(',').append(' ');
    }
    buf.append(iTypes[i].getName());
    buf.append('=');
    buf.append(iValues[i]);
  }
  buf.append(']');
  return buf.toString();
}

代码示例来源:origin: joda-time/joda-time

DateTimeFormatter[] f = iFormatter;
if (f == null) {
  if (size() == 0) {
    return null;

代码示例来源:origin: joda-time/joda-time

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: JodaOrg/joda-time

DateTimeFormatter[] f = iFormatter;
if (f == null) {
  if (size() == 0) {
    return null;

代码示例来源:origin: JodaOrg/joda-time

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

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

public static Set<DurationFieldType> getSupportedDurationFields(Partial p)
{
 Set<DurationFieldType> supportedDurations = Generics.newHashSet();
 for (int i = 0; i < p.size(); i++) {
  supportedDurations.add(p.getFieldType(i).getDurationType());
 }
 return supportedDurations;
}
public static Period getUnsupportedDurationPeriod(Partial p, Period offset)

代码示例来源: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 getPartial(Instant t, Partial p)
{
 Partial res = new Partial(p);
 for (int i = 0; i < p.size(); i++) {
  res = res.withField(p.getFieldType(i), t.get(p.getFieldType(i)));
 }
 return res;
}

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

protected static Period getJodaTimePeriod(Partial p)
{
 if (p.size() > 0) {
  DateTimeFieldType dtType = p.getFieldType(p.size()-1);
  DurationFieldType dType = dtType.getDurationType();
  Period period = new Period();
  if (period.isSupported(dType)) {
   return period.withField(dType, 1);
  } else {
   DurationField df = dType.getField(p.getChronology());
   if (df instanceof ScaledDurationField) {
    ScaledDurationField sdf = (ScaledDurationField) df;
    return period.withField(sdf.getWrappedField().getType(), sdf.getScalar());
   }
   // PeriodType.forFields(new DurationFieldType[]{dType});
   // return new Period(df.getUnitMillis(), PeriodType.forFields(new DurationFieldType[]{dType}));
  }
 }
 return null;
}
public static Partial combineMoreGeneralFields(Partial p1, Partial p2) {

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

public static Partial withWeekYear(Partial p)
{
 Partial res = new Partial();
 for (int i = 0; i < p.size(); i++) {
  DateTimeFieldType fieldType = p.getFieldType(i);
  if (fieldType == DateTimeFieldType.year()) {
   res = res.with(DateTimeFieldType.weekyear(), p.getValue(i));
  } else {
   res = res.with(fieldType, p.getValue(i));
  }
 }
 return res;
}

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

public static Partial discardMoreSpecificFields(Partial p, DurationFieldType dft)
{
 DurationField df = dft.getField(p.getChronology());
 Partial res = new Partial();
 for (int i = 0; i < p.size(); i++) {
  DateTimeFieldType fieldType = p.getFieldType(i);
  DurationField f = fieldType.getDurationType().getField(p.getChronology());
  int cmp = df.compareTo(f);
  if (cmp <= 0) {
   res = res.with(fieldType, p.getValue(i));
  }
 }
 return res;
}

代码示例来源: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

if (p1.size() > 0) {
 p1MostGeneralField = p1.getFieldType(0);    // Assume fields ordered from most general to least....
 mgf = p1MostGeneralField;
for (int i = 0; i < p2.size(); i++) {
 DateTimeFieldType fieldType = p2.getFieldType(i);
 if (fieldType == DateTimeFieldType.year()) {

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Gets a string version of the partial that lists all the fields.
 * <p>
 * This method exists to provide a better debugging toString than
 * the standard toString. This method lists all the fields and their
 * values in a style similar to the collections framework.
 *
 * @return a toString format that lists all the fields
 */
public String toStringList() {
  int size = size();
  StringBuffer buf = new StringBuffer(20 * size);
  buf.append('[');
  for (int i = 0; i < size; i++) {
    if (i > 0) {
      buf.append(',').append(' ');
    }
    buf.append(iTypes[i].getName());
    buf.append('=');
    buf.append(iValues[i]);
  }
  buf.append(']');
  return buf.toString();
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

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

for (int i = 0; i < p2.size(); i++) {
 DateTimeFieldType fieldType = p2.getFieldType(i);
 if (msf == null || isMoreSpecific(fieldType, msf, p.getChronology())) {

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

if (p2 == null) return p1;
Partial p = p1;
for (int i = 0; i < p2.size(); i++) {
 DateTimeFieldType fieldType = p2.getFieldType(i);
 if (fieldType == DateTimeFieldType.year()) {

相关文章