本文整理了Java中org.joda.time.Partial.with()
方法的一些代码示例,展示了Partial.with()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Partial.with()
方法的具体详情如下:
包路径:org.joda.time.Partial
类名称:Partial
方法名:with
[英]Gets a copy of this date with the specified field set to a new value.
If this partial did not previously support the field, the new one will. Contrast this behaviour with #withField(DateTimeFieldType,int).
For example, if the field type is dayOfMonth
then the day would be changed/added in the returned instance.
[中]获取此日期的副本,并将指定字段设置为新值。
如果该部分以前不支持该字段,则新的将支持该字段。将这种行为与#withField(DateTimeFieldType,int)进行对比。
例如,如果字段类型为dayOfMonth
,则将在返回的实例中更改/添加日期。
代码示例来源:origin: stanfordnlp/CoreNLP
protected static Partial setField(Partial base, DateTimeFieldType field, int value) {
if (base == null) {
return new Partial(field, value);
} else {
return base.with(field, value);
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
public static Partial resolveWeek(Partial p1, Partial p2)
{
if (isCompatible(p1,p2)) {
if (!p1.isSupported(DateTimeFieldType.dayOfMonth())) {
if (p2.isSupported(DateTimeFieldType.dayOfMonth()) && p2.isSupported(DateTimeFieldType.monthOfYear()) && p2.isSupported(DateTimeFieldType.year())) {
Instant t2 = getInstant(p2);
DateTime t1 = p1.toDateTime(t2);
return getPartial(t1.toInstant(), p1.without(DateTimeFieldType.dayOfMonth()).without(DateTimeFieldType.monthOfYear()).with(DateTimeFieldType.weekOfWeekyear(), 1));
}
}
}
return p1;
}
public static Partial resolveWeek(Partial p)
代码示例来源: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
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 (p.isSupported(DateTimeFieldType.weekOfWeekyear())) {
if (!p.isSupported(DateTimeFieldType.dayOfMonth()) && !p.isSupported(DateTimeFieldType.dayOfWeek())) {
p = p.with(DateTimeFieldType.dayOfWeek(), 1);
if (p.isSupported(DateTimeFieldType.monthOfYear())) {
p = p.without(DateTimeFieldType.monthOfYear());
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;
p = p.with(fieldType, p2.getValue(i));
代码示例来源: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
p = p.with(DateTimeFieldType.year(), y2);
century--;
p = p.with(DateTimeFieldType.centuryOfEra(), century);
p = p.with(fieldType, p2.getValue(i));
if (p.isSupported(DateTimeFieldType.yearOfCentury()) && p.isSupported(DateTimeFieldType.centuryOfEra())) {
int year = p.get(DateTimeFieldType.yearOfCentury()) + p.get(DateTimeFieldType.centuryOfEra())*100;
p = p.with(DateTimeFieldType.year(), year);
p = p.without(DateTimeFieldType.yearOfCentury());
p = p.without(DateTimeFieldType.centuryOfEra());
代码示例来源:origin: stanfordnlp/CoreNLP
public static Partial resolveWeek(Partial p)
{
// Figure out week
if (p.isSupported(DateTimeFieldType.dayOfMonth()) && p.isSupported(DateTimeFieldType.monthOfYear()) && p.isSupported(DateTimeFieldType.year())) {
Instant t = getInstant(p);
// return getPartial(t.toInstant(), p.without(DateTimeFieldType.dayOfMonth()).without(DateTimeFieldType.monthOfYear()).with(DateTimeFieldType.weekOfWeekyear(), 1));
return getPartial(t.toInstant(), p.with(DateTimeFieldType.weekOfWeekyear(), 1));
} else return p;
}
代码示例来源:origin: stanfordnlp/CoreNLP
p = p.with(DateTimeFieldType.year(), y2);
p = p.with(fieldType, p2.getValue(i));
if (p.isSupported(DateTimeFieldType.yearOfCentury()) && p.isSupported(DateTimeFieldType.centuryOfEra())) {
int year = p.get(DateTimeFieldType.yearOfCentury()) + p.get(DateTimeFieldType.centuryOfEra())*100;
p = p.with(DateTimeFieldType.year(), year);
p = p.without(DateTimeFieldType.yearOfCentury());
p = p.without(DateTimeFieldType.centuryOfEra());
p = p.with(DateTimeFieldType.hourOfDay(), hour);
} else {
p = p.with(DateTimeFieldType.clockhourOfDay(), hour);
代码示例来源: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 resolveDowToDay(Partial p1, Partial p2)
{
// Discard anything that's more specific than dayOfMonth for p2
p2 = JodaTimeUtils.discardMoreSpecificFields(p2, DateTimeFieldType.dayOfMonth());
if (isCompatible(p1,p2)) {
if (p1.isSupported(DateTimeFieldType.dayOfWeek())) {
if (!p1.isSupported(DateTimeFieldType.dayOfMonth())) {
if (p2.isSupported(DateTimeFieldType.dayOfMonth()) && p2.isSupported(DateTimeFieldType.monthOfYear()) && p2.isSupported(DateTimeFieldType.year())) {
Instant t2 = getInstant(p2);
DateTime t1 = p1.toDateTime(t2);
return getPartial(t1.toInstant(), p1.with(DateTimeFieldType.dayOfMonth(), 1)/*.with(DateTimeFieldType.weekOfWeekyear(), 1) */);
}
}
}
}
return p1;
}
代码示例来源:origin: stanfordnlp/CoreNLP
for (DateTimeFieldType dtft : dtFieldTypes) {
if (instant.isSupported(dtft)) {
Partial p2 = JodaTimeUtils.getPartial(instant, p.with(dtft, 1));
t = new PartialTime(JodaTimeUtils.discardMoreSpecificFields(p2, dtft));
代码示例来源:origin: edu.stanford.nlp/stanford-corenlp
protected static Partial setField(Partial base, DateTimeFieldType field, int value) {
if (base == null) {
return new Partial(field, value);
} else {
return base.with(field, value);
}
}
代码示例来源:origin: edu.stanford.nlp/corenlp
protected static Partial setField(Partial base, DateTimeFieldType field, int value) {
if (base == null) {
return new Partial(field, value);
} else {
return base.with(field, value);
}
}
代码示例来源:origin: com.guokr/stan-cn-com
protected static Partial setField(Partial base, DateTimeFieldType field, int value) {
if (base == null) {
return new Partial(field, value);
} else {
return base.with(field, value);
}
}
代码示例来源:origin: spring-projects/Spring-Integration-in-Action
public FlightSchedule(DateTime validFromInclusive, DateTime validUntilExclusive, int flightHourOfDay, int flightMinuteOfHour) {
this.validFromInclusive = validFromInclusive;
this.validUntilInclusive = validUntilExclusive;
flightTimeOfDay = new Partial().with(DateTimeFieldType.hourOfDay(), 12).with(DateTimeFieldType.minuteOfHour(), 30);
}
代码示例来源:origin: FenixEdu/fenixedu-academic
public Partial getStart() {
DateTime start = getActivityInterval().getStart();
return new Partial().with(DateTimeFieldType.year(), start.getYear()).with(DateTimeFieldType.monthOfYear(),
start.getMonthOfYear());
}
代码示例来源:origin: org.opencds.cqf/cql-engine
public static Time expandPartialMin(Time dt, int size) {
for (int i = dt.getPartial().size(); i < size; ++i) {
dt.setPartial(dt.getPartial().with(getField(i), getField(i).getField(null).getMinimumValue()));
}
return dt;
}
}
代码示例来源:origin: org.opencds.cqf/cql-engine
public static DateTime expandPartialMin(DateTime dt, int size) {
for (int i = dt.getPartial().size(); i < size; ++i) {
dt.setPartial(dt.getPartial().with(DateTime.getField(i), DateTime.getField(i).getField(null).getMinimumValue()));
}
return dt;
}
代码示例来源:origin: edu.stanford.nlp/stanford-corenlp
public static Partial resolveWeek(Partial p)
{
// Figure out week
if (p.isSupported(DateTimeFieldType.dayOfMonth()) && p.isSupported(DateTimeFieldType.monthOfYear()) && p.isSupported(DateTimeFieldType.year())) {
Instant t = getInstant(p);
// return getPartial(t.toInstant(), p.without(DateTimeFieldType.dayOfMonth()).without(DateTimeFieldType.monthOfYear()).with(DateTimeFieldType.weekOfWeekyear(), 1));
return getPartial(t.toInstant(), p.with(DateTimeFieldType.weekOfWeekyear(), 1));
} else return p;
}
代码示例来源:origin: com.guokr/stan-cn-com
public static Partial resolveWeek(Partial p)
{
// Figure out week
if (p.isSupported(DateTimeFieldType.dayOfMonth()) && p.isSupported(DateTimeFieldType.monthOfYear()) && p.isSupported(DateTimeFieldType.year())) {
Instant t = getInstant(p);
// return getPartial(t.toInstant(), p.without(DateTimeFieldType.dayOfMonth()).without(DateTimeFieldType.monthOfYear()).with(DateTimeFieldType.weekOfWeekyear(), 1));
return getPartial(t.toInstant(), p.with(DateTimeFieldType.weekOfWeekyear(), 1));
} else return p;
}
内容来源于网络,如有侵权,请联系作者删除!