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


Java OffsetDateTime.parse方法代码示例

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


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

示例1: getInjectable

import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public Injectable<OffsetDateTime> getInjectable(final ComponentContext cc, final QueryParam a) {
    return new Injectable<OffsetDateTime>() {
        @Override
        public OffsetDateTime getValue() {
            final List<String> values = uriInfo.getQueryParameters().get(a.value());

            if (values == null || values.isEmpty())
                return null;
            if (values.size() > 1) {
                throw new WebApplicationException(Response.status(Status.BAD_REQUEST).
                        entity(a.value() + " cannot contain multiple values").build());
            }

            return OffsetDateTime.parse(values.get(0));
        }
    };
}
 
开发者ID:deelam,项目名称:agilion,代码行数:19,代码来源:OffsetDateTimeProvider.java

示例2: convertDateInternal

import java.time.OffsetDateTime; //导入方法依赖的package包/类
static <T> T convertDateInternal(String string, Class<T> type, ZoneId fallbackZoneId) {
   if (java.util.Date.class.equals(type)) {
      return (T) java.util.Date.from(parseInstant(string, fallbackZoneId));
   } else if (java.sql.Date.class.equals(type)) {
      return (T) java.sql.Date.from(parseInstant(string, fallbackZoneId));
   } else if (Time.class.equals(type)) {
      return (T) Time.from(parseInstant(string, fallbackZoneId));
   } else if (Timestamp.class.equals(type)) {
      return (T) Timestamp.from(parseInstant(string, fallbackZoneId));
   } else if (LocalTime.class.equals(type)) {
      return (T) LocalTime.parse(string);
   } else if (LocalDate.class.equals(type)) {
      return (T) LocalDate.parse(string);
   } else if (LocalDateTime.class.equals(type)) {
      return (T) LocalDateTime.parse(string);
   } else if (ZonedDateTime.class.equals(type)) {
      return (T) ZonedDateTime.parse(string);
   } else if (OffsetDateTime.class.equals(type)) {
      return (T) OffsetDateTime.parse(string);
   } else if (OffsetTime.class.equals(type)) {
      return (T) OffsetTime.parse(string);
   }

   return null;
}
 
开发者ID:btc-ag,项目名称:redg,代码行数:26,代码来源:DateConverter.java

示例3: Integration

import java.time.OffsetDateTime; //导入方法依赖的package包/类
public Integration(IdentityImpl identity, String id, String name, IConnection.Type type,
                   String lastSynced, boolean enabled, boolean syncing) {
    super(identity);
    this.id = id;
    this.name = name;
    this.type = type;
    this.lastSynced = OffsetDateTime.parse(lastSynced);
    this.enabled = enabled;
    this.syncing = syncing;
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:11,代码来源:Integration.java

示例4: setMetaData

import java.time.OffsetDateTime; //导入方法依赖的package包/类
public Invite setMetaData(User inviter, int uses, int maxUses, long maxAge, boolean isTemporary, boolean isRevoked, String timeStamp) {
    this.inviter = inviter;
    this.uses = uses;
    this.maxUses = maxUses;
    this.maxAge = maxAge;
    this.isTemporary = isTemporary;
    this.isRevoked = isRevoked;
    this.timeStamp = OffsetDateTime.parse(timeStamp);
    return this;
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:11,代码来源:Invite.java

示例5: deserialze

import java.time.OffsetDateTime; //导入方法依赖的package包/类
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 4) {
        String text = lexer.stringVal();
        lexer.nextToken();
        if (type == LocalDateTime.class) {
            return LocalDateTime.parse(text);
        }
        if (type == LocalDate.class) {
            return LocalDate.parse(text);
        }
        if (type == LocalTime.class) {
            return LocalTime.parse(text);
        }
        if (type == ZonedDateTime.class) {
            return ZonedDateTime.parse(text);
        }
        if (type == OffsetDateTime.class) {
            return OffsetDateTime.parse(text);
        }
        if (type == OffsetTime.class) {
            return OffsetTime.parse(text);
        }
        if (type == ZoneId.class) {
            return ZoneId.of(text);
        }
        if (type == Period.class) {
            return Period.parse(text);
        }
        if (type == Duration.class) {
            return Duration.parse(text);
        }
        if (type == Instant.class) {
            return Instant.parse(text);
        }
        return null;
    }
    throw new UnsupportedOperationException();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:40,代码来源:Jdk8DateCodec.java

示例6: test_parse

import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test(dataProvider="sampleToString")
public void test_parse(int y, int month, int d, int h, int m, int s, int n, String offsetId, String text) {
    OffsetDateTime t = OffsetDateTime.parse(text);
    assertEquals(t.getYear(), y);
    assertEquals(t.getMonth().getValue(), month);
    assertEquals(t.getDayOfMonth(), d);
    assertEquals(t.getHour(), h);
    assertEquals(t.getMinute(), m);
    assertEquals(t.getSecond(), s);
    assertEquals(t.getNano(), n);
    assertEquals(t.getOffset().getId(), offsetId);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:TCKOffsetDateTime.java

示例7: setCreatedTime

import java.time.OffsetDateTime; //导入方法依赖的package包/类
public Message setCreatedTime(String createdTime) {
    this.createdTime = createdTime == null ? null : OffsetDateTime.parse(createdTime);
    return this;
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:5,代码来源:Message.java

示例8: parse

import java.time.OffsetDateTime; //导入方法依赖的package包/类
public static ApiDate parse(String s) {
    OffsetDateTime odt = OffsetDateTime.parse(s);
    return new ApiDate(odt.toEpochSecond());
}
 
开发者ID:oneops,项目名称:secrets-proxy,代码行数:5,代码来源:ApiDate.java

示例9: factory_parse_formatter

import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s XXX");
    OffsetDateTime test = OffsetDateTime.parse("2010 12 3 11 30 0 +01:00", f);
    assertEquals(test, OffsetDateTime.of(LocalDate.of(2010, 12, 3), LocalTime.of(11, 30), ZoneOffset.ofHours(1)));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TCKOffsetDateTime.java

示例10: testWithOffsetWithoutZone

import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test(dataProvider="parseWithOffsetWithoutZone")
public void testWithOffsetWithoutZone(String odtString, OffsetDateTime expectedOTD) {
    dtFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
    odt1 = OffsetDateTime.parse(odtString, dtFormatter);
    assertEquals(expectedOTD, odt1);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TCKDTFParsedInstant.java

示例11: factory_parse_illegalValue

import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_illegalValue() {
    OffsetDateTime.parse("2008-06-32T11:15+01:00");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKOffsetDateTime.java

示例12: factory_parse_invalidValue

import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_invalidValue() {
    OffsetDateTime.parse("2008-06-31T11:15+01:00");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKOffsetDateTime.java

示例13: factory_parse_nullText

import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_nullText() {
    OffsetDateTime.parse((String) null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKOffsetDateTime.java

示例14: factory_parse_formatter_nullFormatter

import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullFormatter() {
    OffsetDateTime.parse("ANY", null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TCKOffsetDateTime.java

示例15: factory_parse_formatter_nullText

import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullText() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s");
    OffsetDateTime.parse((String) null, f);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKOffsetDateTime.java


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