本文整理汇总了Java中org.joda.time.base.BaseSingleFieldPeriod类的典型用法代码示例。如果您正苦于以下问题:Java BaseSingleFieldPeriod类的具体用法?Java BaseSingleFieldPeriod怎么用?Java BaseSingleFieldPeriod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BaseSingleFieldPeriod类属于org.joda.time.base包,在下文中一共展示了BaseSingleFieldPeriod类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
@Override
public Object create(Object request, SpecimenContext context) {
if (!(request instanceof SpecimenType)) {
return new NoSpecimen();
}
SpecimenType type = (SpecimenType) request;
if (!BaseSingleFieldPeriod.class.isAssignableFrom(type.getRawType())) {
return new NoSpecimen();
}
Duration duration = (Duration) context.resolve(Duration.class);
if (type.equals(Seconds.class)) return Seconds.seconds(Math.max(1, (int) duration.getStandardSeconds()));
if (type.equals(Minutes.class)) return Minutes.minutes(Math.max(1, (int) duration.getStandardMinutes()));
if (type.equals(Hours.class)) return Hours.hours(Math.max(1, (int) duration.getStandardHours()));
if (type.equals(Days.class)) return Days.days(Math.max(1, (int) duration.getStandardDays()));
if (type.equals(Weeks.class)) return Weeks.weeks(Math.max(1, (int) duration.getStandardDays() / 7));
if (type.equals(Months.class)) return Months.months(Math.max(1, (int) duration.getStandardDays() / 30));
if (type.equals(Years.class)) return Years.years(Math.max(1, (int) duration.getStandardDays() / 365));
return new NoSpecimen();
}
开发者ID:FlexTradeUKLtd,项目名称:jfixture,代码行数:25,代码来源:BaseSingleFieldPeriodRelay.java
示例2: getPeriodBetweenDates
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
public static Period getPeriodBetweenDates(DateTime sourceDate, DateTime targetDate,
Integer periodUnit, Integer periodValue) {
BaseSingleFieldPeriod retValue;
if (periodUnit == null) {
throw new SessionInternalError("Can't get a period that is null");
}
if (periodUnit.compareTo(Constants.PERIOD_UNIT_DAY) == 0) {
retValue = Days.daysBetween(sourceDate, targetDate).dividedBy(periodValue).multipliedBy(periodValue);
} else if (periodUnit.compareTo(Constants.PERIOD_UNIT_MONTH) == 0) {
retValue = Months.monthsBetween(sourceDate, targetDate).dividedBy(periodValue).multipliedBy(periodValue);
} else if (periodUnit.compareTo(Constants.PERIOD_UNIT_WEEK) == 0) {
retValue = Weeks.weeksBetween(sourceDate, targetDate).dividedBy(periodValue).multipliedBy(periodValue);
} else if (periodUnit.compareTo(Constants.PERIOD_UNIT_YEAR) == 0) {
retValue = Years.yearsBetween(sourceDate, targetDate).dividedBy(periodValue).multipliedBy(periodValue);
} else { // error !
throw new SessionInternalError("Period not supported:" + periodUnit);
}
return retValue.toPeriod();
}
开发者ID:maxdelo77,项目名称:replyit-master-3.2-final,代码行数:23,代码来源:CalendarUtils.java
示例3: TimeWindow
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
public TimeWindow(BaseSingleFieldPeriod duration, DateTime time) {
this.windowDuration = duration;
this.firstInstant = time;
this.lastInstant = time;
// get the epoch (of the first instant's time zone)
MutableDateTime start = new MutableDateTime();
start.setZone(time.getZone());
start.setDate(0);
start.setTime(0);
this.epoch = new DateTime(start);
this.instantSet = new BitSet(windowDuration.toPeriod().toStandardSeconds().getSeconds() / minimunSamplingIntervalInSec);
instantSet.set((int) (new Duration(this.getTimeWindowBeginTime(), time).getStandardSeconds() / minimunSamplingIntervalInSec));
}
开发者ID:ohmage,项目名称:lifestreams,代码行数:15,代码来源:TimeWindow.java
示例4: setTimeWindowSize
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
public BoltConfig setTimeWindowSize(BaseSingleFieldPeriod windowSize) {
if (task instanceof TimeWindowTask) {
((TimeWindowTask) task).setTimeWindowSize(windowSize);
} else {
throw new RuntimeException(
"Only TimeWindowTask should be assigned a window size.");
}
return this;
}
开发者ID:ohmage,项目名称:lifestreams,代码行数:10,代码来源:LifestreamsTopologyBuilder.java
示例5: compareTo
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
@Override
public int compareTo(BaseSingleFieldPeriod other) {
if (!(other instanceof AcademicPeriod)) {
throw new ClassCastException(getClass() + " cannot be compared to " + other.getClass());
}
AcademicPeriod otherAcademicPeriod = (AcademicPeriod) other;
if (getWeight() > otherAcademicPeriod.getWeight()) {
return -1;
} else if (getWeight() < otherAcademicPeriod.getWeight()) {
return 1;
}
return 0;
}
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:16,代码来源:AcademicPeriod.java
示例6: canHandle
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
@Override
public boolean canHandle(Object source, TypeToken<?> targetTypeToken) {
return targetTypeToken.isSubtypeOf(BaseSingleFieldPeriod.class)
&& ((source instanceof Number) || (stringToNumberConverter.canHandle(source, TypeToken.of(Long.class))));
}
开发者ID:keepcosmos,项目名称:beanmother,代码行数:6,代码来源:JodaTimeSingleFieldPeriodConverter.java
示例7: between
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
public static int between(ReadableInstant start, ReadableInstant end, DurationFieldType field) {
return BaseSingleFieldPeriod.between(start, end, field);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:4,代码来源:TestBaseSingleFieldPeriod.java
示例8: standardPeriodIn
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
public static int standardPeriodIn(ReadablePeriod period, long millisPerUnit) {
return BaseSingleFieldPeriod.standardPeriodIn(period, millisPerUnit);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:4,代码来源:TestBaseSingleFieldPeriod.java
示例9: MovesDataCoverage
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
public MovesDataCoverage(BaseSingleFieldPeriod coveragePeriod){
this.coveragePeriod = coveragePeriod;
}
开发者ID:ohmage,项目名称:lifestreams,代码行数:4,代码来源:MovesDataCoverage.java
示例10: MobilityCoverage
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
public MobilityCoverage(BaseSingleFieldPeriod period) {
super(period);
}
开发者ID:ohmage,项目名称:lifestreams,代码行数:4,代码来源:MobilityCoverage.java
示例11: SimpleTimeWindowTask
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
protected SimpleTimeWindowTask(BaseSingleFieldPeriod timeWindowSize) {
super(timeWindowSize);
}
开发者ID:ohmage,项目名称:lifestreams,代码行数:4,代码来源:SimpleTimeWindowTask.java
示例12: TimeWindowTask
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
public TimeWindowTask(BaseSingleFieldPeriod timeWindowSize) {
this.timeWindowSize = timeWindowSize;
}
开发者ID:ohmage,项目名称:lifestreams,代码行数:4,代码来源:TimeWindowTask.java
示例13: setTimeWindowSize
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
public void setTimeWindowSize(BaseSingleFieldPeriod timeWindowSize) {
this.timeWindowSize = timeWindowSize;
}
开发者ID:ohmage,项目名称:lifestreams,代码行数:4,代码来源:TimeWindowTask.java
示例14: aged
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
public static LocalDateRange aged(final Range<? extends BaseSingleFieldPeriod> ageRange) {
return new LocalDateRange(now().minus(ageRange.upperBound()), now().minus(ageRange.lowerBound()));
}
开发者ID:fyodor-org-uk,项目名称:fyodor,代码行数:4,代码来源:LocalDateRange.java
示例15: minutesBetween
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
/**
* Creates a <code>Minutes</code> representing the number of whole minutes
* between the two specified partial datetimes.
* <p>
* The two partials must contain the same fields, for example you can specify
* two <code>LocalTime</code> objects.
*
* @param start the start partial date, must not be null
* @param end the end partial date, must not be null
* @return the period in minutes
* @throws IllegalArgumentException if the partials are null or invalid
*/
public static Minutes minutesBetween(ReadablePartial start, ReadablePartial end) {
if (start instanceof LocalTime && end instanceof LocalTime) {
Chronology chrono = DateTimeUtils.getChronology(start.getChronology());
int minutes = chrono.minutes().getDifference(
((LocalTime) end).getLocalMillis(), ((LocalTime) start).getLocalMillis());
return Minutes.minutes(minutes);
}
int amount = BaseSingleFieldPeriod.between(start, end, ZERO);
return Minutes.minutes(amount);
}
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:23,代码来源:Minutes.java
示例16: minutesIn
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
/**
* Creates a <code>Minutes</code> representing the number of whole minutes
* in the specified interval.
*
* @param interval the interval to extract minutes from, null returns zero
* @return the period in minutes
* @throws IllegalArgumentException if the partials are null or invalid
*/
public static Minutes minutesIn(ReadableInterval interval) {
if (interval == null) {
return Minutes.ZERO;
}
int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.minutes());
return Minutes.minutes(amount);
}
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:16,代码来源:Minutes.java
示例17: weeksBetween
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
/**
* Creates a <code>Weeks</code> representing the number of whole weeks
* between the two specified partial datetimes.
* <p>
* The two partials must contain the same fields, for example you can specify
* two <code>LocalDate</code> objects.
*
* @param start the start partial date, must not be null
* @param end the end partial date, must not be null
* @return the period in weeks
* @throws IllegalArgumentException if the partials are null or invalid
*/
public static Weeks weeksBetween(ReadablePartial start, ReadablePartial end) {
if (start instanceof LocalDate && end instanceof LocalDate) {
Chronology chrono = DateTimeUtils.getChronology(start.getChronology());
int weeks = chrono.weeks().getDifference(
((LocalDate) end).getLocalMillis(), ((LocalDate) start).getLocalMillis());
return Weeks.weeks(weeks);
}
int amount = BaseSingleFieldPeriod.between(start, end, ZERO);
return Weeks.weeks(amount);
}
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:23,代码来源:Weeks.java
示例18: weeksIn
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
/**
* Creates a <code>Weeks</code> representing the number of whole weeks
* in the specified interval.
*
* @param interval the interval to extract weeks from, null returns zero
* @return the period in weeks
* @throws IllegalArgumentException if the partials are null or invalid
*/
public static Weeks weeksIn(ReadableInterval interval) {
if (interval == null) {
return Weeks.ZERO;
}
int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.weeks());
return Weeks.weeks(amount);
}
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:16,代码来源:Weeks.java
示例19: secondsBetween
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
/**
* Creates a <code>Seconds</code> representing the number of whole seconds
* between the two specified partial datetimes.
* <p>
* The two partials must contain the same fields, for example you can specify
* two <code>LocalTime</code> objects.
*
* @param start the start partial date, must not be null
* @param end the end partial date, must not be null
* @return the period in seconds
* @throws IllegalArgumentException if the partials are null or invalid
*/
public static Seconds secondsBetween(ReadablePartial start, ReadablePartial end) {
if (start instanceof LocalTime && end instanceof LocalTime) {
Chronology chrono = DateTimeUtils.getChronology(start.getChronology());
int seconds = chrono.seconds().getDifference(
((LocalTime) end).getLocalMillis(), ((LocalTime) start).getLocalMillis());
return Seconds.seconds(seconds);
}
int amount = BaseSingleFieldPeriod.between(start, end, ZERO);
return Seconds.seconds(amount);
}
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:23,代码来源:Seconds.java
示例20: secondsIn
import org.joda.time.base.BaseSingleFieldPeriod; //导入依赖的package包/类
/**
* Creates a <code>Seconds</code> representing the number of whole seconds
* in the specified interval.
*
* @param interval the interval to extract seconds from, null returns zero
* @return the period in seconds
* @throws IllegalArgumentException if the partials are null or invalid
*/
public static Seconds secondsIn(ReadableInterval interval) {
if (interval == null) {
return Seconds.ZERO;
}
int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.seconds());
return Seconds.seconds(amount);
}
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:16,代码来源:Seconds.java
注:本文中的org.joda.time.base.BaseSingleFieldPeriod类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论