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


Java ZonedDateTime.parse方法代码示例

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


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

示例1: test_AWS_SIG4_request_is_chained

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void test_AWS_SIG4_request_is_chained() throws IOException {
    ZonedDateTime aDate = ZonedDateTime.parse("2015-08-30T12:36:00.000Z", DateTimeFormatter.ISO_DATE_TIME);
    Supplier<ZonedDateTime> clock = () -> aDate;
    AwsSigningInterceptor interceptor = new AwsSigningInterceptor(cfg, clock);

    Request req = createExampleRequest()
            .build();

    Interceptor.Chain chain = mock(Interceptor.Chain.class);
    when(chain.request()).thenReturn(req);

    interceptor.intercept(chain);

    verify(chain, times(1)).proceed(any());
}
 
开发者ID:esiqveland,项目名称:okhttp-awssigner,代码行数:17,代码来源:AwsSigningInterceptorTest.java

示例2: parseRegularLine

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private void parseRegularLine(String line, LogEntry precessor) throws LogParserException {
    String[] tokens = line.split(" ", 3);
    if (tokens.length == 3) {
        String dateString = tokens[0];
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PersistentAppender.DATE_FORMAT);
        ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateString, formatter);
        timestamp = zonedDateTime.toInstant().toEpochMilli();
        String levelString = tokens[1];
        level = Level.valueOf(levelString);
        message = tokens[2];
        if (precessor != null) {
            index = precessor.index + 1;
        } else {
            index = 0;
        }
    } else {
        throw new LogParserException(line);
    }
}
 
开发者ID:StuPro-TOSCAna,项目名称:TOSCAna,代码行数:20,代码来源:LogEntry.java

示例3: initDataForDailyTimeFrame

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Before
public void initDataForDailyTimeFrame(){

    String[] dataLine = rawData_5_minutes.split("\n");
    List<Tick> ticks = new ArrayList<>();
    for (int i = 0; i < dataLine.length; i++) {
        String[] tickData = dataLine[i].split(",");
        ZonedDateTime date = ZonedDateTime.parse(tickData[0]+" "+tickData[1]+" PST", DateTimeFormatter.ofPattern("yyyy-MM-dd H:m:s z"));
        double open = Double.parseDouble(tickData[2]);
        double high = Double.parseDouble(tickData[3]);
        double low = Double.parseDouble(tickData[4]);
        double close = Double.parseDouble(tickData[5]);
        double volume = Double.parseDouble(tickData[6]);
        ticks.add(new BaseTick(date, open, high, low, close, volume));
    }
    series_5_minutes = new BaseTimeSeries("FB_5_minutes", ticks);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:18,代码来源:PivotPointIndicatorTest.java

示例4: load

import java.time.ZonedDateTime; //导入方法依赖的package包/类
public void load(ResultSet rs) throws SQLException {
    this.id = rs.getInt("id");
    this.name = rs.getString("name");
    this.uuid = rs.getString("uuid");
    this.ip = rs.getString("ip");
    this.type = PunishmentType.valueOf(rs.getString("type"));
    this.endTime = ZonedDateTime.parse(rs.getString("endTime"));
    this.reason = rs.getString("reason");
    this.giver = rs.getString("giver");
    this.startTime = ZonedDateTime.parse(rs.getString("startTime"));
    this.cancelled = Boolean.parseBoolean(rs.getString("cancelled"));
    if (this.cancelled) {
        this.canceller = rs.getString("canceller");
        this.cancelTime = ZonedDateTime.parse(rs.getString("cancelTime"));
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:17,代码来源:Punishment.java

示例5: parseTime

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private ZonedDateTime parseTime(String time) {
  // TODO : may support more than one format at some point
  DateTimeFormatter dtf =
      DateTimeFormatter.ofPattern(Schedule.DATETIME_FORMATS[0]).withZone(ZoneId.systemDefault());
  ZonedDateTime zdt = null;

  try {
    zdt = ZonedDateTime.parse(time, dtf);
  } catch (DateTimeParseException e) {
    logger.debug("parseTime() failed to parse '" + time + "'");
    // throw an exception
    // mark as complete (via max iterations?)
  }

  return zdt;
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:17,代码来源:ScheduleContext.java

示例6: decode

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public ZonedDateTime decode(
        BsonReader reader,
        DecoderContext decoderContext) {

    return ZonedDateTime.parse(reader.readString());
}
 
开发者ID:cbartosiak,项目名称:bson-codecs-jsr310,代码行数:8,代码来源:ZonedDateTimeCodec.java

示例7: validateBetList

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private static void validateBetList(Parameter parameter) throws PinnacleException {
	Validator validator = new Validator(parameter);
	validator.addRequiredKey("betlist");
	validator.addRequiredKey("fromDate");
	validator.addRequiredKey("toDate");
	validator.validateKeys();
	ZonedDateTime from = ZonedDateTime.parse((String) validator.getValue("fromDate"));
	ZonedDateTime to = ZonedDateTime.parse((String) validator.getValue("toDate"));
	if (to.isAfter(from.plusDays(30)) || !to.isAfter(from)) {
		throw PinnacleException.parameterInvalid(
				"fromDate must be earlier than toDate and the difference between them must be less than 30 days.");
	}
}
 
开发者ID:gentoku,项目名称:pinnacle-api-client,代码行数:14,代码来源:Validators.java

示例8: getLastCommitDate

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private ZonedDateTime getLastCommitDate(String resAsString){
	Map<String,List<LinkedTreeMap>> resMap = gson.fromJson(resAsString, Map.class);

	List<LinkedTreeMap> values = resMap.get(VALUES);

	if(values != null){
		values.sort(Comparator.comparing(v -> ZonedDateTime.parse(v.get("date").toString())));
		LinkedTreeMap lastValue = values.get(values.size() - 1);
		return ZonedDateTime.parse(lastValue.get("date").toString());
	}

	return null;
}
 
开发者ID:mgustavocoder,项目名称:hard-worker-activity-stream,代码行数:14,代码来源:BitbucketClient.java

示例9: test_parse

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test(dataProvider="sampleToString")
public void test_parse(int y, int month, int d, int h, int m, int s, int n, String zoneId, String text) {
    ZonedDateTime t = ZonedDateTime.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.getZone().getId(), zoneId);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:TCKZonedDateTime.java

示例10: constructSamlResponse

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Construct SAML response.
 * <a href="http://bit.ly/1uI8Ggu">See this reference for more info.</a>
 *
 * @param service the service
 * @return the SAML response
 */
protected String constructSamlResponse(final GoogleAccountsService service) {
    final ZonedDateTime currentDateTime = ZonedDateTime.now(ZoneOffset.UTC);
    final ZonedDateTime notBeforeIssueInstant = ZonedDateTime.parse("2003-04-17T00:46:02Z");
    final RegisteredService registeredService = servicesManager.findServiceBy(service);
    if (registeredService == null || !registeredService.getAccessStrategy().isServiceAccessAllowed()) {
        throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE);
    }
    final String userId = registeredService.getUsernameAttributeProvider().resolveUsername(service.getPrincipal(), service, registeredService);

    final org.opensaml.saml.saml2.core.Response response = this.samlObjectBuilder.newResponse(
            this.samlObjectBuilder.generateSecureRandomId(), currentDateTime, null, service);
    response.setStatus(this.samlObjectBuilder.newStatus(StatusCode.SUCCESS, null));

    final String sessionIndex = '_' + String.valueOf(Math.abs(new SecureRandom().nextLong()));
    final AuthnStatement authnStatement = this.samlObjectBuilder.newAuthnStatement(AuthnContext.PASSWORD_AUTHN_CTX, currentDateTime, sessionIndex);
    final Assertion assertion = this.samlObjectBuilder.newAssertion(authnStatement, casServerPrefix,
            notBeforeIssueInstant, this.samlObjectBuilder.generateSecureRandomId());

    final Conditions conditions = this.samlObjectBuilder.newConditions(notBeforeIssueInstant,
            currentDateTime.plusSeconds(this.skewAllowance), service.getId());
    assertion.setConditions(conditions);

    final Subject subject = this.samlObjectBuilder.newSubject(NameID.EMAIL, userId,
            service.getId(), currentDateTime.plusSeconds(this.skewAllowance), service.getRequestId());
    assertion.setSubject(subject);

    response.getAssertions().add(assertion);

    final StringWriter writer = new StringWriter();
    this.samlObjectBuilder.marshalSamlXmlObject(response, writer);

    final String result = writer.toString();
    LOGGER.debug("Generated Google SAML response: [{}]", result);
    return result;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:43,代码来源:GoogleAccountsServiceResponseBuilder.java

示例11: read

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public ZonedDateTime read(JsonReader in) throws IOException {
    if (!in.hasNext()) {
        return null;
    }
    return ZonedDateTime.parse(in.nextString(), Operation.DATE_TIME_FORMATTER);
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:8,代码来源:ZonedDateTimeJsonAdapter.java

示例12: parseLiteral

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public ZonedDateTime parseLiteral(Object input) {
    if (input instanceof StringValue) {
        return ZonedDateTime.parse(((StringValue) input).getValue());
    } else if (input instanceof IntValue) {
        return Instant.ofEpochMilli(((IntValue) input).getValue().longValue()).atZone(ZoneOffset.UTC);
    } else {
        return null;
    }
}
 
开发者ID:howtographql,项目名称:graphql-java,代码行数:11,代码来源:Scalars.java

示例13: test_parseAdditional

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test(dataProvider="parseAdditional")
public void test_parseAdditional(String text, int y, int month, int d, int h, int m, int s, int n, String zoneId) {
    ZonedDateTime t = ZonedDateTime.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.getZone().getId(), zoneId);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:TCKZonedDateTime.java

示例14: toTimestamp

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private Timestamp toTimestamp(String zonedDateTime) {
    if (zonedDateTime == null) {
        return null;
    }
    ZonedDateTime parsedZonedDateTime = ZonedDateTime.parse(zonedDateTime, Operation.DATE_TIME_FORMATTER);
    return new Timestamp(parsedZonedDateTime.toInstant().toEpochMilli());
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:8,代码来源:AlterOperationTableTimestampStoringColumns.java

示例15: read

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public ZonedDateTime read(JsonReader in) throws IOException {
    return ZonedDateTime.parse(in.nextString());
}
 
开发者ID:CROW-NDOV,项目名称:displaydirect,代码行数:5,代码来源:ZonedDateTimeAdapter.java


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