當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。