类org.joda.time.DateTimeFieldType源码实例Demo

下面列出了怎么用org.joda.time.DateTimeFieldType的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: SimFix   文件: 1_ImpreciseDateTimeField.java
/**
     * Constructor.
     * 
     * @param type  the field type
     * @param unitMillis  the average duration unit milliseconds
     */
    public ImpreciseDateTimeField(DateTimeFieldType type, long unitMillis) {
// start of generated patch
super(type);
if(type==null){
throw new IllegalArgumentException("The type must not be null");
}
iUnitMillis=unitMillis;
iDurationField=new LinkedDurationField(type.getDurationType());
// end of generated patch
/* start of original code
        super(type);
        iUnitMillis = unitMillis;
        iDurationField = new LinkedDurationField(type.getDurationType());
 end of original code*/
    }
 
源代码2 项目: astor   文件: BasicChronology.java
public long getDateTimeMillis(
        int year, int monthOfYear, int dayOfMonth,
        int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)
        throws IllegalArgumentException {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth,
                                      hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }

    FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23);
    FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999);

    return getDateMidnightMillis(year, monthOfYear, dayOfMonth)
        + hourOfDay * DateTimeConstants.MILLIS_PER_HOUR
        + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE
        + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND
        + millisOfSecond;
}
 
源代码3 项目: astor   文件: OffsetDateTimeField.java
/**
 * Constructor.
 * 
 * @param field  the field to wrap, like "year()".
 * @param type  the field type this field actually uses
 * @param offset  offset to add to field values
 * @param minValue  minimum allowed value
 * @param maxValue  maximum allowed value
 * @throws IllegalArgumentException if offset is zero
 */
public OffsetDateTimeField(DateTimeField field, DateTimeFieldType type, int offset,
                           int minValue, int maxValue) {
    super(field, type);
            
    if (offset == 0) {
        throw new IllegalArgumentException("The offset cannot be zero");
    }

    iOffset = offset;

    if (minValue < (field.getMinimumValue() + offset)) {
        iMin = field.getMinimumValue() + offset;
    } else {
        iMin = minValue;
    }
    if (maxValue > (field.getMaximumValue() + offset)) {
        iMax = field.getMaximumValue() + offset;
    } else {
        iMax = maxValue;
    }
}
 
源代码4 项目: astor   文件: ISODateTimeFormat.java
private static DateTimeFormatter basicOrdinalDate() {
    if (bod == null) {
        return new DateTimeFormatterBuilder()
            .appendYear(4, 4)
            .appendFixedDecimal(DateTimeFieldType.dayOfYear(), 3)
            .toFormatter();
    }
    return bod;
}
 
@Override
public int getMaximumValue(ReadablePartial partial) {
  if (partial.isSupported(DateTimeFieldType.monthOfYear())) {
    int month = partial.get(DateTimeFieldType.monthOfYear());
    return this.daysInMonth[month - 1]; // Months are 1-based
  }
  return this.getMaximumValue();
}
 
源代码6 项目: fenixedu-academic   文件: Summary.java
private void fillSummaryWithInfo(LocalizedString title, LocalizedString summaryText, Integer studentsNumber,
        Boolean isExtraLesson, Professorship professorship, String teacherName, Teacher teacher, Shift shift, Lesson lesson,
        YearMonthDay day, Space room, Partial hour, ShiftType type, Boolean taught, Boolean onlineLesson) {

    setShift(shift);
    setSummaryDateYearMonthDay(day);
    setExecutionCourse(shift.getExecutionCourse());
    setTitle(title);
    setSummaryText(summaryText);
    setIsExtraLesson(isExtraLesson);

    checkSpecialParameters(isExtraLesson, professorship, teacherName, teacher, lesson, hour, type);
    checkIfInternalTeacherHasProfessorhipInExecutionCourse(teacher, shift.getExecutionCourse());
    checkIfSummaryDateIsValid(day, shift.getExecutionPeriod(), lesson, isExtraLesson);

    setStudentsNumber(studentsNumber);
    setProfessorship(professorship);
    setTeacherName(teacherName);
    setTeacher(teacher);
    setLastModifiedDateDateTime(new DateTime());
    setSummaryType(type);
    setTaught(taught);
    setOnlineLesson(onlineLesson);

    if (isExtraLesson) {
        super.setLessonInstance(null);
        setRoom(room);
        HourMinuteSecond hourMinuteSecond =
                new HourMinuteSecond(hour.get(DateTimeFieldType.hourOfDay()), hour.get(DateTimeFieldType.minuteOfHour()), 0);
        setSummaryHourHourMinuteSecond(hourMinuteSecond);
    } else {
        setRoom(lesson.getSala());
        setSummaryHourHourMinuteSecond(lesson.getBeginHourMinuteSecond());
        lessonInstanceManagement(lesson, day, lesson.getSala());
        if (getLessonInstance() == null) {
            throw new DomainException("error.Summary.empty.LessonInstances");
        }
    }
}
 
源代码7 项目: joda-time-android   文件: DateUtils.java
/**
 * See {@link android.text.format.DateUtils#isToday} for full docs.
 *
 * @return true if the supplied when is today else false
 */
public static boolean isToday(ReadablePartial time) {
    if (!time.isSupported(DateTimeFieldType.dayOfMonth())
        || !time.isSupported(DateTimeFieldType.monthOfYear())
        || !time.isSupported(DateTimeFieldType.year())) {
        throw new IllegalArgumentException("isToday() must be passed a ReadablePartial that supports day of " +
            "month, month of year and year.");
    }

    LocalDate localDate = time instanceof LocalDate ? (LocalDate) time : new LocalDate(time);
    return LocalDate.now().compareTo(localDate) == 0;
}
 
源代码8 项目: crate   文件: StrictISODateTimeFormat.java
private static DateTimeFormatter weekyearElement() {
    if (WE == null) {
        return new DateTimeFormatterBuilder()
            .appendFixedSignedDecimal(DateTimeFieldType.weekyear(), 4)
            .toFormatter();
    }
    return WE;
}
 
public PhdGratuityPaymentPeriod(int dayStart, int monthStart, int dayEnd, int monthEnd, int dayLastPayment,
        int monthLastPayment) {
    super();
    init(new Partial().with(DateTimeFieldType.monthOfYear(), monthStart).with(DateTimeFieldType.dayOfYear(), dayStart),
            new Partial().with(DateTimeFieldType.monthOfYear(), monthEnd).with(DateTimeFieldType.dayOfYear(), dayEnd),
            new Partial().with(DateTimeFieldType.monthOfYear(), monthLastPayment).with(DateTimeFieldType.dayOfYear(),
                    dayLastPayment));
}
 
源代码10 项目: Elasticsearch   文件: StrictISODateTimeFormat.java
private static DateTimeFormatter yearElement() {
    if (ye == null) {
        return new DateTimeFormatterBuilder()
                .appendFixedSignedDecimal(DateTimeFieldType.year(), 4) // ES change, was .appendYear(4, 9)
                .toFormatter();
    }
    return ye;
}
 
源代码11 项目: Elasticsearch   文件: StrictISODateTimeFormat.java
private static DateTimeFormatter monthElement() {
    if (mye == null) {
        return new DateTimeFormatterBuilder()
                .appendLiteral('-')
                .appendFixedSignedDecimal(DateTimeFieldType.monthOfYear(), 2) // ES change, was .appendMonthOfYear(2)
                .toFormatter();
    }
    return mye;
}
 
源代码12 项目: Elasticsearch   文件: StrictISODateTimeFormat.java
private static DateTimeFormatter weekyearElement() {
    if (we == null) {
        return new DateTimeFormatterBuilder()
                .appendFixedSignedDecimal(DateTimeFieldType.weekyear(), 4) // ES change, was .appendWeekyear(4, 9)
                .toFormatter();
    }
    return we;
}
 
源代码13 项目: Elasticsearch   文件: StrictISODateTimeFormat.java
private static DateTimeFormatter weekElement() {
    if (wwe == null) {
        return new DateTimeFormatterBuilder()
                .appendLiteral("-W")
                .appendFixedSignedDecimal(DateTimeFieldType.weekOfWeekyear(), 2) // ES change, was .appendWeekOfWeekyear(2)
                .toFormatter();
    }
    return wwe;
}
 
源代码14 项目: Elasticsearch   文件: StrictISODateTimeFormat.java
private static DateTimeFormatter hourElement() {
    if (hde == null) {
        return new DateTimeFormatterBuilder()
                .appendFixedSignedDecimal(DateTimeFieldType.hourOfDay(), 2) // ES change, was .appendHourOfDay(2)
                .toFormatter();
    }
    return hde;
}
 
源代码15 项目: fenixedu-academic   文件: Attends.java
public Interval getWeeklyWorkLoadInterval() {
    final DateTime beginningOfSemester = new DateTime(getBegginingOfLessonPeriod());
    final DateTime firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
    final DateTime endOfSemester = new DateTime(getEndOfExamsPeriod());
    final DateTime nextLastMonday = endOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1).plusWeeks(1);
    return new Interval(firstMonday, nextLastMonday);
}
 
源代码16 项目: SimFix   文件: 1_UnsupportedDateTimeField.java
/**
     * Constructor.
     * 
     * @param type  the field type
     * @param durationField  the duration to use
     */
    private UnsupportedDateTimeField(DateTimeFieldType type, DurationField durationField) {
// start of generated patch
if(type==null||durationField==null){
throw new IllegalArgumentException("The type must not be null");
}
// end of generated patch
/* start of original code
        if (type == null || durationField == null) {
            throw new IllegalArgumentException();
        }
 end of original code*/
        iType = type;
        iDurationField = durationField;
    }
 
源代码17 项目: fenixedu-academic   文件: MonthsPartialProvider.java
@Override
public Object provide(Object source, Object currentValue) {
    List<Partial> result = new ArrayList<Partial>();
    for (int i = 1; i <= 12; i++) {
        result.add(new Partial(DateTimeFieldType.monthOfYear(), i));
    }
    return result;
}
 
源代码18 项目: astor   文件: ISODateTimeFormat.java
/**
 * Returns a basic formatter for a full date as four digit weekyear, two
 * digit week of weekyear, and one digit day of week (xxxx'W'wwe).
 * 
 * @return a formatter for xxxx'W'wwe
 */
public static DateTimeFormatter basicWeekDate() {
    if (bwd == null) {
        bwd = new DateTimeFormatterBuilder()
            .appendWeekyear(4, 4)
            .appendLiteral('W')
            .appendFixedDecimal(DateTimeFieldType.weekOfWeekyear(), 2)
            .appendFixedDecimal(DateTimeFieldType.dayOfWeek(), 1)
            .toFormatter();
    }
    return bwd;
}
 
源代码19 项目: astor   文件: BasicMonthOfYearDateTimeField.java
/**
 * Restricted constructor.
 * 
 * @param leapMonth the month of year that leaps
 */
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth) {
    super(DateTimeFieldType.monthOfYear(), chronology.getAverageMillisPerMonth());
    iChronology = chronology;
    iMax = iChronology.getMaxMonth();
    iLeapMonth = leapMonth;
}
 
源代码20 项目: astor   文件: DividedDateTimeField.java
/**
 * Constructor.
 * 
 * @param field  the field to wrap, like "year()".
 * @param type  the field type this field will actually use
 * @param divisor  divisor, such as 100 years in a century
 * @throws IllegalArgumentException if divisor is less than two
 */
public DividedDateTimeField(DateTimeField field,
                            DateTimeFieldType type, int divisor) {
    super(field, type);
            
    if (divisor < 2) {
        throw new IllegalArgumentException("The divisor must be at least 2");
    }

    DurationField unitField = field.getDurationField();
    if (unitField == null) {
        iDurationField = null;
    } else {
        iDurationField = new ScaledDurationField(
            unitField, type.getDurationType(), divisor);
    }

    iDivisor = divisor;

    int i = field.getMinimumValue();
    int min = (i >= 0) ? i / divisor : ((i + 1) / divisor - 1);

    int j = field.getMaximumValue();
    int max = (j >= 0) ? j / divisor : ((j + 1) / divisor - 1);

    iMin = min;
    iMax = max;
}
 
源代码21 项目: coming   文件: Nopol2017_0088_t.java
/**
 * Gets the milliseconds for a date at midnight.
 * 
 * @param year  the year
 * @param monthOfYear  the month
 * @param dayOfMonth  the day
 * @return the milliseconds
 */
long getDateMidnightMillis(int year, int monthOfYear, int dayOfMonth) {
    FieldUtils.verifyValueBounds(DateTimeFieldType.year(), year, getMinYear(), getMaxYear());
    FieldUtils.verifyValueBounds(DateTimeFieldType.monthOfYear(), monthOfYear, 1, getMaxMonth(year));
    if ((!(10 == monthOfYear)) && (((31) - (2)) != (dayOfMonth))) {
        FieldUtils.verifyValueBounds(DateTimeFieldType.dayOfMonth(), dayOfMonth, 1, getDaysInYearMonth(year, monthOfYear));
    }
    return getYearMonthDayMillis(year, monthOfYear, dayOfMonth);
}
 
源代码22 项目: coming   文件: Nopol2017_0086_t.java
/**
 * Restricted constructor.
 * 
 * @param leapMonth the month of year that leaps
 */
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth) {
    super(DateTimeFieldType.monthOfYear(), chronology.getAverageMillisPerMonth());
    iChronology = chronology;
    iMax = iChronology.getMaxMonth();
    iLeapMonth = leapMonth;
}
 
源代码23 项目: astor   文件: TestISODateTimeFormat.java
public void testFormat_time_partial() {
    Partial dt = new Partial(
            new DateTimeFieldType[] {DateTimeFieldType.hourOfDay(), DateTimeFieldType.minuteOfHour(),
                    DateTimeFieldType.secondOfMinute(), DateTimeFieldType.millisOfSecond()},
            new int[] {10, 20, 30, 40});
    assertEquals("10:20:30.040", ISODateTimeFormat.time().print(dt));
}
 
源代码24 项目: astor   文件: DateTimeFormatterBuilder.java
/**
 * Instructs the printer to emit a remainder of time as a decimal fraction,
 * without decimal point. For example, if the field is specified as
 * minuteOfHour and the time is 12:30:45, the value printed is 75. A
 * decimal point is implied, so the fraction is 0.75, or three-quarters of
 * a minute.
 *
 * @param fieldType  type of field to append
 * @param minDigits  minimum number of digits to print.
 * @param maxDigits  maximum number of digits to print or parse.
 * @return this DateTimeFormatterBuilder, for chaining
 * @throws IllegalArgumentException if field type is null
 */
public DateTimeFormatterBuilder appendFraction(
        DateTimeFieldType fieldType, int minDigits, int maxDigits) {
    if (fieldType == null) {
        throw new IllegalArgumentException("Field type must not be null");
    }
    if (maxDigits < minDigits) {
        maxDigits = minDigits;
    }
    if (minDigits < 0 || maxDigits <= 0) {
        throw new IllegalArgumentException();
    }
    return append0(new Fraction(fieldType, minDigits, maxDigits));
}
 
源代码25 项目: astor   文件: TestPreciseDateTimeField.java
public void test_getType() {
    BaseDateTimeField field = new PreciseDateTimeField(
        DateTimeFieldType.secondOfDay(),
        ISOChronology.getInstanceUTC().millis(),
        ISOChronology.getInstanceUTC().hours()
    );
    assertEquals(DateTimeFieldType.secondOfDay(), field.getType());
}
 
源代码26 项目: crate   文件: StrictISODateTimeFormat.java
private static DateTimeFormatter dayOfYearElement() {
    if (DYE == null) {
        return new DateTimeFormatterBuilder()
            .appendLiteral('-')
            .appendFixedSignedDecimal(DateTimeFieldType.dayOfYear(), 3)
            .toFormatter();
    }
    return DYE;
}
 
protected Fraction(DateTimeFieldType fieldType, int minDigits, int maxDigits) {
    super();
    iFieldType = fieldType;
    // Limit the precision requirements.
    if (maxDigits > 18) {
        maxDigits = 18;
    }
    iMinDigits = minDigits;
    iMaxDigits = maxDigits;
}
 
源代码28 项目: astor   文件: TestPreciseDateTimeField.java
public void test_toString() {
    BaseDateTimeField field = new PreciseDateTimeField(
        DateTimeFieldType.secondOfDay(),
        ISOChronology.getInstanceUTC().millis(),
        ISOChronology.getInstanceUTC().hours()
    );
    assertEquals("DateTimeField[secondOfDay]", field.toString());
}
 
private static Map<String, DateTimeFieldType> getMap() {
    Map<String, DateTimeFieldType> ret = new HashMap<>();
    ret.put(DateTimeFieldType.centuryOfEra().getName(), DateTimeFieldType.centuryOfEra());
    ret.put(DateTimeFieldType.clockhourOfDay().getName(), DateTimeFieldType.clockhourOfDay());
    ret.put(DateTimeFieldType.clockhourOfHalfday().getName(), DateTimeFieldType.clockhourOfHalfday());
    ret.put(DateTimeFieldType.dayOfMonth().getName(), DateTimeFieldType.dayOfMonth());
    ret.put(DateTimeFieldType.dayOfWeek().getName(), DateTimeFieldType.dayOfWeek());
    ret.put(DateTimeFieldType.dayOfYear().getName(), DateTimeFieldType.dayOfYear());
    ret.put(DateTimeFieldType.era().getName(), DateTimeFieldType.era());
    ret.put(DateTimeFieldType.halfdayOfDay().getName(), DateTimeFieldType.halfdayOfDay());
    ret.put(DateTimeFieldType.hourOfDay().getName(), DateTimeFieldType.hourOfDay());
    ret.put(DateTimeFieldType.hourOfHalfday().getName(), DateTimeFieldType.hourOfHalfday());
    ret.put(DateTimeFieldType.millisOfDay().getName(), DateTimeFieldType.millisOfDay());
    ret.put(DateTimeFieldType.millisOfSecond().getName(), DateTimeFieldType.millisOfSecond());
    ret.put(DateTimeFieldType.minuteOfDay().getName(), DateTimeFieldType.minuteOfDay());
    ret.put(DateTimeFieldType.minuteOfHour().getName(), DateTimeFieldType.minuteOfHour());
    ret.put(DateTimeFieldType.secondOfDay().getName(), DateTimeFieldType.secondOfDay());
    ret.put(DateTimeFieldType.secondOfMinute().getName(), DateTimeFieldType.secondOfMinute());
    ret.put(DateTimeFieldType.weekOfWeekyear().getName(), DateTimeFieldType.weekOfWeekyear());
    ret.put(DateTimeFieldType.weekyear().getName(), DateTimeFieldType.weekyear());
    ret.put(DateTimeFieldType.weekyearOfCentury().getName(), DateTimeFieldType.weekyearOfCentury());
    ret.put(DateTimeFieldType.year().getName(), DateTimeFieldType.year());
    ret.put(DateTimeFieldType.yearOfCentury().getName(), DateTimeFieldType.yearOfCentury());
    ret.put(DateTimeFieldType.yearOfEra().getName(), DateTimeFieldType.yearOfEra());

    return ret;
}
 
源代码30 项目: unitime   文件: QueryLog.java
ChartWindow(String name, String format,
		ReadablePeriod start, int window, ReadablePeriod increment,
		String axeFormat, DateTimeFieldType axeType, int axeMod, int axeValue, int minutes, String base,
		String oracleFormat, String oracleCondition, String mySqlFormat, String mySqlCondition) {
	iName = name;
	iFormat = new SimpleDateFormat(format, Locale.US);
	iStart = start; iWindow = window; iIncrement = increment;
	iAxeFormat = axeFormat; iAxeType = axeType; iAxeMod = axeMod; iAxeValue = axeValue;
	iMinutes = minutes; iBase = base;
	iOracleFormat = oracleFormat; iOracleCondition = oracleCondition;
	iMySqlFormat = mySqlFormat; iMySqlCondition = mySqlCondition;
}
 
 类所在包
 同包方法