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


Java Joda.forPattern方法代码示例

本文整理汇总了Java中org.elasticsearch.common.joda.Joda.forPattern方法的典型用法代码示例。如果您正苦于以下问题:Java Joda.forPattern方法的具体用法?Java Joda.forPattern怎么用?Java Joda.forPattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.joda.Joda的用法示例。


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

示例1: RangeQueryBuilder

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
/**
 * Read from a stream.
 */
public RangeQueryBuilder(StreamInput in) throws IOException {
    super(in);
    fieldName = in.readString();
    from = in.readGenericValue();
    to = in.readGenericValue();
    includeLower = in.readBoolean();
    includeUpper = in.readBoolean();
    timeZone = in.readOptionalTimeZone();
    String formatString = in.readOptionalString();
    if (formatString != null) {
        format = Joda.forPattern(formatString);
    }
    if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
        String relationString = in.readOptionalString();
        if (relationString != null) {
            relation = ShapeRelation.getRelationByName(relationString);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:RangeQueryBuilder.java

示例2: testThatEpochParserIsIdempotent

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
public void testThatEpochParserIsIdempotent() {
    FormatDateTimeFormatter formatter = Joda.forPattern("epoch_millis");
    DateTime dateTime = formatter.parser().parseDateTime("1234567890123");
    assertThat(dateTime.getMillis(), is(1234567890123L));
    dateTime = formatter.printer().parseDateTime("1234567890456");
    assertThat(dateTime.getMillis(), is(1234567890456L));
    dateTime = formatter.parser().parseDateTime("1234567890789");
    assertThat(dateTime.getMillis(), is(1234567890789L));
    dateTime = formatter.parser().parseDateTime("1234567890123456789");
    assertThat(dateTime.getMillis(), is(1234567890123456789L));

    FormatDateTimeFormatter secondsFormatter = Joda.forPattern("epoch_second");
    DateTime secondsDateTime = secondsFormatter.parser().parseDateTime("1234567890");
    assertThat(secondsDateTime.getMillis(), is(1234567890000L));
    secondsDateTime = secondsFormatter.printer().parseDateTime("1234567890");
    assertThat(secondsDateTime.getMillis(), is(1234567890000L));
    secondsDateTime = secondsFormatter.parser().parseDateTime("1234567890");
    assertThat(secondsDateTime.getMillis(), is(1234567890000L));
    secondsDateTime = secondsFormatter.parser().parseDateTime("1234567890123456");
    assertThat(secondsDateTime.getMillis(), is(1234567890123456000L));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:SimpleJodaTests.java

示例3: docValueFormat

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
@Override
public DocValueFormat docValueFormat(@Nullable String format, DateTimeZone timeZone) {
    FormatDateTimeFormatter dateTimeFormatter = this.dateTimeFormatter;
    if (format != null) {
        dateTimeFormatter = Joda.forPattern(format);
    }
    if (timeZone == null) {
        timeZone = DateTimeZone.UTC;
    }
    return new DocValueFormat.DateTime(dateTimeFormatter, timeZone);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:DateFieldMapper.java

示例4: valueOf

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
@Override
public java.lang.Long valueOf(String value, String fmt) {
    FormatDateTimeFormatter f = formatter;
    if (fmt != null) {
        f = Joda.forPattern(fmt);
    }
    return f.parser().parseDateTime(value).getMillis();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:FieldStats.java

示例5: Timestamp

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
public Timestamp(boolean enabled, String path, String format, String defaultTimestamp, Boolean ignoreMissing) {
    this.enabled = enabled;
    this.path = path;
    if (path == null) {
        pathElements = Strings.EMPTY_ARRAY;
    } else {
        pathElements = Strings.delimitedListToStringArray(path, ".");
    }
    this.format = format;
    this.dateTimeFormatter = Joda.forPattern(format);
    this.defaultTimestamp = defaultTimestamp;
    this.ignoreMissing = ignoreMissing;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:MappingMetaData.java

示例6: valueOf

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
@Override
protected java.lang.Long valueOf(String value, String optionalFormat) {
    FormatDateTimeFormatter dateFormatter = this.dateFormatter;
    if (optionalFormat != null) {
        dateFormatter = Joda.forPattern(optionalFormat);
    }
    return dateFormatter.parser().parseMillis(value);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:FieldStats.java

示例7: testSlashInFormat

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
public void testSlashInFormat() {
    FormatDateTimeFormatter formatter = Joda.forPattern("MM/yyyy");
    formatter.parser().parseMillis("01/2001");

    formatter = Joda.forPattern("yyyy/MM/dd HH:mm:ss");
    long millis = formatter.parser().parseMillis("1970/01/01 00:00:00");
    formatter.printer().print(millis);

    try {
        millis = formatter.parser().parseMillis("1970/01/01");
        fail();
    } catch (IllegalArgumentException e) {
        // it really can't parse this one
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:SimpleJodaTests.java

示例8: expectInvalidPattern

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
private void expectInvalidPattern(String pattern, String errorMessage) {
    try {
        Joda.forPattern(pattern);
        fail("Pattern " + pattern + " should have thrown an exception but did not");
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), containsString(errorMessage));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:SimpleJodaTests.java

示例9: testThatNegativeEpochsCanBeParsed

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
public void testThatNegativeEpochsCanBeParsed() {
    // problem: negative epochs can be arbitrary in size...
    boolean parseMilliSeconds = randomBoolean();
    FormatDateTimeFormatter formatter = Joda.forPattern(parseMilliSeconds ? "epoch_millis" : "epoch_second");
    DateTime dateTime = formatter.parser().parseDateTime("-10000");

    assertThat(dateTime.getYear(), is(1969));
    assertThat(dateTime.getMonthOfYear(), is(12));
    assertThat(dateTime.getDayOfMonth(), is(31));
    if (parseMilliSeconds) {
        assertThat(dateTime.getHourOfDay(), is(23)); // utc timezone, +2 offset due to CEST
        assertThat(dateTime.getMinuteOfHour(), is(59));
        assertThat(dateTime.getSecondOfMinute(), is(50));
    } else {
        assertThat(dateTime.getHourOfDay(), is(21)); // utc timezone, +2 offset due to CEST
        assertThat(dateTime.getMinuteOfHour(), is(13));
        assertThat(dateTime.getSecondOfMinute(), is(20));
    }

    // every negative epoch must be parsed, no matter if exact the size or bigger
    if (parseMilliSeconds) {
        formatter.parser().parseDateTime("-100000000");
        formatter.parser().parseDateTime("-999999999999");
        formatter.parser().parseDateTime("-1234567890123");
        formatter.parser().parseDateTime("-1234567890123456789");
    } else {
        formatter.parser().parseDateTime("-100000000");
        formatter.parser().parseDateTime("-1234567890");
        formatter.parser().parseDateTime("-1234567890123456");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:SimpleJodaTests.java

示例10: testThatEpochParserIsPrinter

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
public void testThatEpochParserIsPrinter() {
    FormatDateTimeFormatter formatter = Joda.forPattern("epoch_millis");
    assertThat(formatter.parser().isPrinter(), is(true));
    assertThat(formatter.printer().isPrinter(), is(true));

    FormatDateTimeFormatter epochSecondFormatter = Joda.forPattern("epoch_second");
    assertThat(epochSecondFormatter.parser().isPrinter(), is(true));
    assertThat(epochSecondFormatter.printer().isPrinter(), is(true));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:SimpleJodaTests.java

示例11: DateTime

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
public DateTime(StreamInput in) throws IOException {
    this(Joda.forPattern(in.readString()), DateTimeZone.forID(in.readString()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:DocValueFormat.java

示例12: parseDateTimeFormatter

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
public static FormatDateTimeFormatter parseDateTimeFormatter(Object node) {
    return Joda.forPattern(node.toString());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:TypeParsers.java

示例13: readFrom

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    dateFormatter =  Joda.forPattern(in.readString());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:FieldStats.java

示例14: readFrom

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    formatter = Joda.forPattern(in.readString());
    timeZone = DateTimeZone.forID(in.readString());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:ValueFormatter.java

示例15: DateTime

import org.elasticsearch.common.joda.Joda; //导入方法依赖的package包/类
public DateTime(String format, DateTimeZone timezone) {
    this.formatter = Joda.forPattern(format);
    this.timeZone = timezone != null ? timezone : DateTimeZone.UTC;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:ValueFormatter.java


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