当前位置: 首页>>代码示例>>Java>>正文


Java DateTimeFieldType类代码示例

本文整理汇总了Java中org.joda.time.DateTimeFieldType的典型用法代码示例。如果您正苦于以下问题:Java DateTimeFieldType类的具体用法?Java DateTimeFieldType怎么用?Java DateTimeFieldType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DateTimeFieldType类属于org.joda.time包,在下文中一共展示了DateTimeFieldType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dateByOrdinal

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
/**
 * Creates a date using the ordinal date format.
 * Specification reference: 5.2.2.
 *
 * @param bld  the builder
 * @param fields  the fields
 * @param extended  true to use extended format
 * @since 1.1
 */
private static boolean dateByOrdinal(
        DateTimeFormatterBuilder bld,
        Collection<DateTimeFieldType> fields,
        boolean extended) {

    boolean reducedPrec = false;
    if (fields.remove(DateTimeFieldType.year())) {
        bld.append(Constants.ye);
        if (fields.remove(DateTimeFieldType.dayOfYear())) {
            // YYYY-DDD/YYYYDDD
            appendSeparator(bld, extended);
            bld.appendDayOfYear(3);
        } else {
            // YYYY/YYYY
            reducedPrec = true;
        }

    } else if (fields.remove(DateTimeFieldType.dayOfYear())) {
        // -DDD/-DDD
        bld.appendLiteral('-');
        bld.appendDayOfYear(3);
    }
    return reducedPrec;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:StrictISODateTimeFormat.java

示例2: dateByOrdinal

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
/**
 * Creates a date using the ordinal date format.
 * Specification reference: 5.2.2.
 *
 * @param bld  the builder
 * @param fields  the fields
 * @param extended  true to use extended format
 * @param strictISO  true to only allow ISO formats
 * @since 1.1
 */
private static boolean dateByOrdinal(
        DateTimeFormatterBuilder bld,
        Collection<DateTimeFieldType> fields,
        boolean extended,
        boolean strictISO) {

    boolean reducedPrec = false;
    if (fields.remove(DateTimeFieldType.year())) {
        bld.append(Constants.ye);
        if (fields.remove(DateTimeFieldType.dayOfYear())) {
            // YYYY-DDD/YYYYDDD
            appendSeparator(bld, extended);
            bld.appendDayOfYear(3);
        } else {
            // YYYY/YYYY
            reducedPrec = true;
        }

    } else if (fields.remove(DateTimeFieldType.dayOfYear())) {
        // -DDD/-DDD
        bld.appendLiteral('-');
        bld.appendDayOfYear(3);
    }
    return reducedPrec;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:36,代码来源:StrictISODateTimeFormat.java

示例3: onDateTimePicked

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
@Override
public void onDateTimePicked(DateTime d) {
    searchDateTime = d;

    DateTime now = new DateTime();

    DateTimeFormatter df = DateTimeFormat.forPattern("dd MMMM yyyy");
    DateTimeFormatter tf = DateTimeFormat.forPattern("HH:mm");

    String day = df.print(searchDateTime);
    String time = tf.print(searchDateTime);
    String at = getActivity().getResources().getString(R.string.time_at);

    if (now.get(DateTimeFieldType.year()) == searchDateTime.get(DateTimeFieldType.year())) {
        if (now.get(DateTimeFieldType.dayOfYear()) == searchDateTime.get(DateTimeFieldType.dayOfYear())) {
            day = getActivity().getResources().getString(R.string.time_today);
        } else  //noinspection RedundantCast
            if (now.get(DateTimeFieldType.dayOfYear()) + 1 == (int) searchDateTime.get(DateTimeFieldType.dayOfYear())) {
                day = getActivity().getResources().getString(R.string.time_tomorrow);
            }
    }
    vDatetime.setText(day + " " + at + " " + time);
}
 
开发者ID:hyperrail,项目名称:hyperrail-for-android,代码行数:24,代码来源:RouteSearchFragment.java

示例4: setData

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
public void setData(List<Event> events, GregorianCalendar calendar) {
    _eventsToDisplay = new ArrayList<>();
    this._calendar = calendar;
    for (Event e : events) {
        DateTime beginTime = e.getBeginDateTime();
        DateTime endTime = e.getEndDateTime();

        if (beginTime.get(DateTimeFieldType.dayOfYear()) <= calendar.get(Calendar.DAY_OF_YEAR)
                && beginTime.get(DateTimeFieldType.year()) <= calendar.get(Calendar.YEAR)
                && endTime.get(DateTimeFieldType.dayOfYear()) >= calendar.get(Calendar.DAY_OF_YEAR)
                && endTime.get(DateTimeFieldType.year()) >= calendar.get(Calendar.DAY_OF_YEAR)) {
            _eventsToDisplay.add(e);
        }
    }
    if(_view != null){
        setAdapter();
    }
}
 
开发者ID:DerGary,项目名称:FHWS-Lectures,代码行数:19,代码来源:EventListFragment.java

示例5: RemainderDateTimeField

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param field  the field to wrap, like "year()".
 * @param type  the field type this field actually uses
 * @param divisor  divisor, such as 100 years in a century
 * @throws IllegalArgumentException if divisor is less than two
 */
public RemainderDateTimeField(DateTimeField field,
                              DateTimeFieldType type, int divisor) {
    super(field, type);

    if (divisor < 2) {
        throw new IllegalArgumentException("The divisor must be at least 2");
    }

    DurationField rangeField = field.getDurationField();
    if (rangeField == null) {
        iRangeField = null;
    } else {
        iRangeField = new ScaledDurationField(
            rangeField, type.getRangeDurationType(), divisor);
    }

    iDivisor = divisor;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:27,代码来源:RemainderDateTimeField.java

示例6: PreciseDateTimeField

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param type  the field type this field uses
 * @param unit  precise unit duration, like "seconds()".
 * @param range precise range duration, preferably a multiple of the unit,
 * like "minutes()".
 * @throws IllegalArgumentException if either duration field is imprecise
 * @throws IllegalArgumentException if unit milliseconds is less than one
 * or effective value range is less than two.
 */
public PreciseDateTimeField(DateTimeFieldType type,
                            DurationField unit, DurationField range) {
    super(type, unit);

    if (!range.isPrecise()) {
        throw new IllegalArgumentException("Range duration field must be precise");
    }

    long rangeMillis = range.getUnitMillis();
    iRange = (int)(rangeMillis / getUnitMillis());
    if (iRange < 2) {
        throw new IllegalArgumentException("The effective range must be at least 2");
    }

    iRangeField = range;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:28,代码来源:PreciseDateTimeField.java

示例7: DividedDateTimeField

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
/**
 * Construct a DividedDateTimeField that compliments the given
 * RemainderDateTimeField.
 *
 * @param remainderField  complimentary remainder field, like "yearOfCentury()".
 * @param type  the field type this field will actually use
 */
public DividedDateTimeField(RemainderDateTimeField remainderField, DateTimeFieldType type) {
    super(remainderField.getWrappedField(), type);
    int divisor = iDivisor = remainderField.iDivisor;
    iDurationField = remainderField.iRangeField;

    DateTimeField field = getWrappedField();
    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;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:23,代码来源:DividedDateTimeField.java

示例8: getDateTimeMillis

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
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;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:22,代码来源:BasicChronology.java

示例9: postponedAssertDateEquals

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
@Deprecated
protected void postponedAssertDateEquals(DateTime actualDate, DateTime expectedDate, String dateFieldName) {
    postponedAssertEquals(actualDate.year().get(), expectedDate.year().get(), "Incorrect field 'year' in " + dateFieldName);
    postponedAssertEquals(actualDate.monthOfYear().get(), expectedDate.monthOfYear().get(), "Incorrect field 'month' in " + dateFieldName);
    postponedAssertEquals(actualDate.dayOfMonth().get(), expectedDate.dayOfMonth().get(), "Incorrect field 'day' in " + dateFieldName);
    postponedAssertEquals(actualDate.hourOfDay().get(), expectedDate.hourOfDay().get(), "Incorrect field 'hour' in " + dateFieldName);
    postponedAssertTrue(Math.abs(actualDate.minuteOfHour().get() - expectedDate.minuteOfHour().get()) <= 1,
            "Incorrect field 'minute' in " + dateFieldName + ". Actual - " + actualDate.minuteOfHour().get()
                    + " . Expected - " + expectedDate.minuteOfHour().get());
    postponedAssertEquals(actualDate.get(DateTimeFieldType.halfdayOfDay()), expectedDate.get(DateTimeFieldType.halfdayOfDay()),
            "Incorrect field 'halfdayOfDay' in start date" + dateFieldName);
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:13,代码来源:AbstractPageElement.java

示例10: main

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
public static void main(String[] args) throws NoSuchAlgorithmException {
	
	SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
	for (int i=1; i<=1440; i++) {
		System.out.println("maps.put(\"20141109-"+i+"\", \""+sr.nextInt(10)+" "+sr.nextInt(10)+" "+sr.nextInt(10)+" "+sr.nextInt(10)+" "+sr.nextInt(10)+"\");");
	}
	
	System.out.println(LocalDate.now());
	Instant in = new Instant(1414508801016L);
	DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
	formatter=formatter.withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT+8")));
	
	in = in.plus(100);
	
	System.out.println(in.get(DateTimeFieldType.millisOfSecond()));
	
	System.out.println(in.toDate());
	System.out.println(formatter.print(in));
	System.out.println(in.getMillis());
	Pattern pattern = Pattern.compile("\"phase\":\"20141018023\"(.*)\"data\":\\[\"(\\d)\",\"(\\d)\",\"(\\d)\",\"(\\d)\",\"(\\d)\"\\]\\}\\]\\}");
	Matcher matcher = pattern.matcher("{\"code\":0,\"message\":\"\",\"data\":[{\"phasetype\":200,\"phase\":\"20141018023\",\"create_at\":\"2014-01-21 14:41:05\",\"time_startsale\":\"2014-10-18 01:50:00\",\"time_endsale\":\"2014-10-18 01:55:00\",\"time_endticket\":\"2014-10-18 01:55:00\",\"time_draw\":\"2014-10-18 01:56:00\",\"status\":5,\"forsale\":0,\"is_current\":0,\"result\":{\"result\":[{\"key\":\"ball\",\"data\":[\"1\",\"5\",\"0\",\"5\",\"9\"]}]},\"result_detail\":{\"resultDetail\":[{\"key\":\"prize1\",\"bet\":\"0\",\"prize\":100000},{\"key\":\"prize2\",\"bet\":\"0\",\"prize\":20000},{\"key\":\"prize3\",\"bet\":\"0\",\"prize\":200},{\"key\":\"prize4\",\"bet\":\"0\",\"prize\":20},{\"key\":\"prize5\",\"bet\":\"0\",\"prize\":1000},{\"key\":\"prize6\",\"bet\":\"0\",\"prize\":320},{\"key\":\"prize7\",\"bet\":\"0\",\"prize\":160},{\"key\":\"prize8\",\"bet\":\"0\",\"prize\":100},{\"key\":\"prize9\",\"bet\":\"0\",\"prize\":50},{\"key\":\"prize10\",\"bet\":\"0\",\"prize\":10},{\"key\":\"prize11\",\"bet\":\"0\",\"prize\":4}]},\"pool_amount\":\"\",\"sale_amount\":\"\",\"ext\":\"\",\"fc3d_sjh\":null,\"terminal_status\":2,\"fordraw\":0,\"time_startsale_fixed\":\"2014-10-18 01:47:40\",\"time_endsale_fixed\":\"2014-10-18 01:52:40\",\"time_endsale_syndicate_fixed\":\"2014-10-18 01:55:00\",\"time_endsale_upload_fixed\":\"2014-10-18 01:55:00\",\"time_draw_fixed\":\"2014-10-18 01:56:00\",\"time_startsale_correction\":140,\"time_endsale_correction\":140,\"time_endsale_syndicate_correction\":0,\"time_endsale_upload_correction\":0,\"time_draw_correction\":0,\"time_exchange\":\"2014-12-16 01:56:00\"},{\"phasetype\":\"200\",\"phase\":\"20141018024\",\"create_at\":\"2014-01-21 14:41:05\",\"time_startsale\":\"2014-10-18 01:55:00\",\"time_endsale\":\"2014-10-18 10:00:00\",\"time_endticket\":\"2014-10-18 10:00:00\",\"time_draw\":\"2014-10-18 10:01:00\",\"status\":\"2\",\"forsale\":\"1\",\"is_current\":\"1\",\"result\":null,\"result_detail\":null,\"pool_amount\":\"\",\"sale_amount\":\"\",\"ext\":\"\",\"fc3d_sjh\":null,\"terminal_status\":\"1\",\"fordraw\":\"0\",\"time_startsale_fixed\":\"2014-10-18 01:52:40\",\"time_endsale_fixed\":\"2014-10-18 09:57:40\",\"time_endsale_syndicate_fixed\":\"2014-10-18 10:00:00\",\"time_endsale_upload_fixed\":\"2014-10-18 10:00:00\",\"time_draw_fixed\":\"2014-10-18 10:01:00\",\"time_startsale_correction\":140,\"time_endsale_correction\":140,\"time_endsale_syndicate_correction\":0,\"time_endsale_upload_correction\":0,\"time_draw_correction\":0,\"time_exchange\":\"2014-12-16 10:01:00\"}],\"redirect\":\"\",\"datetime\":\"2014-10-18 04:08:45\",\"timestamp\":1413576525}");
	
	//Pattern pattern = Pattern.compile("(.*)message(\\d\\d)(\\d)(\\d)(\\d)");
	//Matcher matcher = pattern.matcher("23fawef_message12345");
	//Pattern pattern = Pattern.compile("\"number\":\"(\\d) (\\d) (\\d) (\\d) (\\d)\",\"period\":\"20141017083");
	//Matcher matcher = pattern.matcher("{\"latestPeriods\":[{\"number\":\"6 0 2 2 1\",\"period\":\"20141017084\"},{\"number\":\"0 8 9 1 9\",\"period\":\"20141017083\"},{\"number\":\"4 0 4 4 6\",\"period\":\"20141017082\"},{\"number\":\"4 5 8 7 7\",\"period\":\"20141017081\"},{\"number\":\"7 2 8 5 3\",\"period\":\"20141017080\"},{\"number\":\"9 7 3 8 0\",\"period\":\"20141017079\"},{\"number\":\"3 7 6 0 1\",\"period\":\"20141017078\"},{\"number\":\"9 6 4 8 5\",\"period\":\"20141017077\"},{\"number\":\"6 4 1 8 1\",\"period\":\"20141017076\"},{\"number\":\"9 5 2 8 7\",\"period\":\"20141017075\"}],\"successful\":\"true\",\"statusDesc\":\"获取数据成功\"}");
	
	matcher.find();
	for (int i=1; i<=matcher.groupCount(); i++) {
		
			System.out.println(matcher.group(i));
		
	}
}
 
开发者ID:onsoul,项目名称:os,代码行数:35,代码来源:BillNoUtils.java

示例11: basicDate

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
private static DateTimeFormatter basicDate() {
    if (bd == null) {
        return new DateTimeFormatterBuilder()
                .appendYear(4, 4)
                .appendFixedDecimal(DateTimeFieldType.monthOfYear(), 2)
                .appendFixedDecimal(DateTimeFieldType.dayOfMonth(), 2)
                .toFormatter();
    }
    return bd;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:StrictISODateTimeFormat.java

示例12: basicTime

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
private static DateTimeFormatter basicTime() {
    if (bt == null) {
        return new DateTimeFormatterBuilder()
                .appendFixedDecimal(DateTimeFieldType.hourOfDay(), 2)
                .appendFixedDecimal(DateTimeFieldType.minuteOfHour(), 2)
                .appendFixedDecimal(DateTimeFieldType.secondOfMinute(), 2)
                .appendLiteral('.')
                .appendFractionOfSecond(3, 9)
                .appendTimeZoneOffset("Z", false, 2, 2)
                .toFormatter();
    }
    return bt;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:StrictISODateTimeFormat.java

示例13: basicTimeNoMillis

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
private static DateTimeFormatter basicTimeNoMillis() {
    if (btx == null) {
        return new DateTimeFormatterBuilder()
                .appendFixedDecimal(DateTimeFieldType.hourOfDay(), 2)
                .appendFixedDecimal(DateTimeFieldType.minuteOfHour(), 2)
                .appendFixedDecimal(DateTimeFieldType.secondOfMinute(), 2)
                .appendTimeZoneOffset("Z", false, 2, 2)
                .toFormatter();
    }
    return btx;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:StrictISODateTimeFormat.java

示例14: basicOrdinalDate

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
private static DateTimeFormatter basicOrdinalDate() {
    if (bod == null) {
        return new DateTimeFormatterBuilder()
                .appendYear(4, 4)
                .appendFixedDecimal(DateTimeFieldType.dayOfYear(), 3)
                .toFormatter();
    }
    return bod;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:StrictISODateTimeFormat.java

示例15: basicWeekDate

import org.joda.time.DateTimeFieldType; //导入依赖的package包/类
private static DateTimeFormatter basicWeekDate() {
    if (bwd == null) {
        return new DateTimeFormatterBuilder()
                .appendFixedSignedDecimal(DateTimeFieldType.weekyear(), 4) // ES change, was .appendWeekyear(4, 4)
                .appendLiteral('W')
                .appendFixedDecimal(DateTimeFieldType.weekOfWeekyear(), 2)
                .appendFixedDecimal(DateTimeFieldType.dayOfWeek(), 1)
                .toFormatter();
    }
    return bwd;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:StrictISODateTimeFormat.java


注:本文中的org.joda.time.DateTimeFieldType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。