當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTimeZone.UTC屬性代碼示例

本文整理匯總了Java中org.joda.time.DateTimeZone.UTC屬性的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeZone.UTC屬性的具體用法?Java DateTimeZone.UTC怎麽用?Java DateTimeZone.UTC使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.joda.time.DateTimeZone的用法示例。


在下文中一共展示了DateTimeZone.UTC屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTaxCodesValidAt

@Test(groups = "fast")
public void getTaxCodesValidAt() throws IOException, ServletException, SQLException {
    // given
    ByteArrayOutputStream byos = givenDefaultServletCall("GET", "/taxCodes");
    given(req.getParameter(EasyTaxServlet.VALID_DATE)).willReturn("2017-01-01T12:00:00Z");

    List<EasyTaxTaxCode> taxCodes = Arrays
            .asList(new EasyTaxTaxCode(UUID.randomUUID().toString()));
    DateTime at = new DateTime(2017, 1, 1, 12, 0, 0, DateTimeZone.UTC);
    given(dao.getTaxCodes(tenantId, null, null, null, at)).willReturn(taxCodes);

    // when
    servlet.service(req, res);

    // then
    thenDefaultOkJsonResponse();

    assertEquals(byos.toString("UTF-8"),
            "[{\"tax_code\":\"" + taxCodes.get(0).getTaxCode() + "\"}]",
            "Response body content");
}
 
開發者ID:SolarNetwork,項目名稱:killbill-easytax-plugin,代碼行數:21,代碼來源:EasyTaxServletTests.java

示例2: testReuters1

@Test
public void testReuters1() throws Exception {
    String html = loadArticle("reuters1");
    String url = "http://www.reuters.com/finance/stocks/TEX/key-developments/article/3414284";
    HttpArticle article = ArticleExtractor.extractArticle(html, url, reutersSource(), null);
    assertEquals("Marcato reports 5.1 pct stake in Terex, to urge spinoff & restructuring- CNBC, citing source", article.getTitle());
    assertTrue(article.getText().contains("Marcato reports 5.1 pct stake in Terex, to urge spinoff & restructuring; Marcato supports Terex CEO - CNBC, citing source"));
    DateTime actualPublished = article.getPublished();
    DateTime expectedPublished = new DateTime(2016, 7, 28, 15, 35, DateTimeZone.UTC);
    assertTrue(actualPublished.toDate().equals(expectedPublished.toDate()));
}
 
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:11,代碼來源:ReutersExtractorTest.java

示例3: testUTCIntervalRounding

public void testUTCIntervalRounding() {
    Rounding tzRounding = Rounding.builder(TimeValue.timeValueHours(12)).build();
    DateTimeZone tz = DateTimeZone.UTC;
    assertThat(tzRounding.round(time("2009-02-03T01:01:01")), isDate(time("2009-02-03T00:00:00.000Z"), tz));
    assertThat(tzRounding.nextRoundingValue(time("2009-02-03T00:00:00.000Z")), isDate(time("2009-02-03T12:00:00.000Z"), tz));
    assertThat(tzRounding.round(time("2009-02-03T13:01:01")), isDate(time("2009-02-03T12:00:00.000Z"), tz));
    assertThat(tzRounding.nextRoundingValue(time("2009-02-03T12:00:00.000Z")), isDate(time("2009-02-04T00:00:00.000Z"), tz));

    tzRounding = Rounding.builder(TimeValue.timeValueHours(48)).build();
    assertThat(tzRounding.round(time("2009-02-03T01:01:01")), isDate(time("2009-02-03T00:00:00.000Z"), tz));
    assertThat(tzRounding.nextRoundingValue(time("2009-02-03T00:00:00.000Z")), isDate(time("2009-02-05T00:00:00.000Z"), tz));
    assertThat(tzRounding.round(time("2009-02-05T13:01:01")), isDate(time("2009-02-05T00:00:00.000Z"), tz));
    assertThat(tzRounding.nextRoundingValue(time("2009-02-05T00:00:00.000Z")), isDate(time("2009-02-07T00:00:00.000Z"), tz));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:14,代碼來源:TimeZoneRoundingTests.java

示例4: returnDateIsMandatoryForClosedLoans

@Test
@Ignore("Should conditional field validation be done in a storage module?")
public void returnDateIsMandatoryForClosedLoans()
  throws InterruptedException,
  MalformedURLException,
  TimeoutException,
  ExecutionException {

  DateTime loanDate = new DateTime(2017, 3, 1, 13, 25, 46, 232, DateTimeZone.UTC);

  IndividualResource loan = createLoan(new LoanRequestBuilder()
    .withLoanDate(loanDate)
    .withdueDate(loanDate.plus(Period.days(14)))
    .create());

  JsonObject returnedLoan = loan.copyJson();

  returnedLoan
    .put("status", new JsonObject().put("name", "Closed"));

  CompletableFuture<TextResponse> putCompleted = new CompletableFuture();

  client.put(loanStorageUrl(String.format("/%s", loan.getId())), returnedLoan,
    StorageTestSuite.TENANT_ID, ResponseHandler.text(putCompleted));

  TextResponse response = putCompleted.get(5, TimeUnit.SECONDS);

  assertThat(String.format("Should have failed to update loan: %s", response.getBody()),
    response.getStatusCode(), is(HttpURLConnection.HTTP_BAD_REQUEST));

  assertThat(response.getBody(),
    containsString("return date is mandatory to close a loan"));
}
 
開發者ID:folio-org,項目名稱:mod-circulation-storage,代碼行數:33,代碼來源:LoansApiTest.java

示例5: formatToZulu

/**
 * Normalise isoDate time to Zulu(UTC0) time-zone, removing any UTC offset.
 * @param isoDate
 * @return the ISO Zulu timezone formatted string 
 *             e.g 2011-02-04T17:13:14.000+01:00 -> 2011-02-04T16:13:14.000Z
 */
public static String formatToZulu(String isoDate)
{
    try 
    {
        DateTime dt = new DateTime(isoDate, DateTimeZone.UTC);
        return dt.toString();
    } catch (IllegalArgumentException e) 
    {
        throw new AlfrescoRuntimeException("Failed to parse date " + isoDate, e);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:17,代碼來源:ISO8601DateFormat.java

示例6: setup

@BeforeMethod
public void setup() {
    now = new DateTime(DateTimeZone.UTC);
    tenantId = UUID.randomUUID();
    tenant = mock(Tenant.class);
    clock = mock(Clock.class);
    dao = mock(EasyTaxDao.class);
    securityApi = mock(SecurityApi.class);
    servlet = new EasyTaxServlet(dao, clock, securityApi);
    req = mock(HttpServletRequest.class);
    res = mock(HttpServletResponse.class);
}
 
開發者ID:SolarNetwork,項目名稱:killbill-easytax-plugin,代碼行數:12,代碼來源:EasyTaxServletTests.java

示例7: testUnixMs

public void testUnixMs() {
    DateProcessor dateProcessor = new DateProcessor(randomAsciiOfLength(10), DateTimeZone.UTC, randomLocale(random()),
            "date_as_string", Collections.singletonList("UNIX_MS"), "date_as_date");
    Map<String, Object> document = new HashMap<>();
    document.put("date_as_string", "1000500");
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document);
    dateProcessor.execute(ingestDocument);
    assertThat(ingestDocument.getFieldValue("date_as_date", String.class), equalTo("1970-01-01T00:16:40.500Z"));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:9,代碼來源:DateProcessorTests.java

示例8: RequestRequestBuilder

public RequestRequestBuilder() {
  this(UUID.randomUUID(),
    "Hold",
    new DateTime(2017, 7, 15, 9, 35, 27, DateTimeZone.UTC),
    UUID.randomUUID(),
    UUID.randomUUID(),
    "Hold Shelf",
    null,
    null,
    null,
    null,
    null);
}
 
開發者ID:folio-org,項目名稱:mod-circulation-storage,代碼行數:13,代碼來源:RequestRequestBuilder.java

示例9: DateTime

public DateTime(String format, DateTimeZone timezone) {
    this.formatter = Joda.forPattern(format);
    this.timeZone = timezone != null ? timezone : DateTimeZone.UTC;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:4,代碼來源:ValueFormatter.java

示例10: getUtcMinDateTime

@Test
public void getUtcMinDateTime() throws Exception {
    DateTime result = client.datetimes().getUtcMinDateTime();
    DateTime expected = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
    Assert.assertEquals(expected, result);
}
 
開發者ID:Azure,項目名稱:autorest.java,代碼行數:6,代碼來源:DatetimeOperationsTests.java

示例11: canCreateARequestWithOnlyRequiredProperties

@Test
public void canCreateARequestWithOnlyRequiredProperties()
  throws InterruptedException,
  MalformedURLException,
  TimeoutException,
  ExecutionException,
  UnsupportedEncodingException {

  CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();

  UUID id = UUID.randomUUID();
  UUID itemId = UUID.randomUUID();
  UUID requesterId = UUID.randomUUID();
  DateTime requestDate = new DateTime(2017, 7, 22, 10, 22, 54, DateTimeZone.UTC);

  JsonObject requestRequest = new RequestRequestBuilder()
    .recall()
    .withId(id)
    .withRequestDate(requestDate)
    .withItemId(itemId)
    .withRequesterId(requesterId)
    .toHoldShelf()
    .create();

  client.post(requestStorageUrl(),
    requestRequest, StorageTestSuite.TENANT_ID,
    ResponseHandler.json(createCompleted));

  JsonResponse response = createCompleted.get(5, TimeUnit.SECONDS);

  assertThat(String.format("Failed to create request: %s", response.getBody()),
    response.getStatusCode(), is(HttpURLConnection.HTTP_CREATED));

  JsonObject representation = response.getJson();

  assertThat(representation.getString("id"), is(id.toString()));
  assertThat(representation.getString("requestType"), is("Recall"));
  assertThat(representation.getString("requestDate"), is(equivalentTo(requestDate)));
  assertThat(representation.getString("itemId"), is(itemId.toString()));
  assertThat(representation.getString("requesterId"), is(requesterId.toString()));
  assertThat(representation.getString("fulfilmentPreference"), is("Hold Shelf"));
  assertThat(representation.containsKey("requestExpirationDate"), is(false));
  assertThat(representation.containsKey("holdShelfExpirationDate"), is(false));
  assertThat(representation.containsKey("item"), is(false));
  assertThat(representation.containsKey("requester"), is(false));
}
 
開發者ID:folio-org,項目名稱:mod-circulation-storage,代碼行數:46,代碼來源:RequestsApiTest.java

示例12: canCreateARequest

@Test
public void canCreateARequest()
  throws InterruptedException,
  MalformedURLException,
  TimeoutException,
  ExecutionException,
  UnsupportedEncodingException {

  CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();

  UUID id = UUID.randomUUID();
  UUID itemId = UUID.randomUUID();
  UUID requesterId = UUID.randomUUID();
  DateTime requestDate = new DateTime(2017, 7, 22, 10, 22, 54, DateTimeZone.UTC);

  JsonObject requestRequest = new RequestRequestBuilder()
    .recall()
    .toHoldShelf()
    .withId(id)
    .withRequestDate(requestDate)
    .withItemId(itemId)
    .withRequesterId(requesterId)
    .withRequestExpiration(new LocalDate(2017, 7, 30))
    .withHoldShelfExpiration(new LocalDate(2017, 8, 31))
    .withItem("Nod", "565578437802")
    .withRequester("Jones", "Stuart", "Anthony", "6837502674015")
    .create();

  client.post(requestStorageUrl(),
    requestRequest, StorageTestSuite.TENANT_ID,
    ResponseHandler.json(createCompleted));

  JsonResponse response = createCompleted.get(5, TimeUnit.SECONDS);

  assertThat(String.format("Failed to create request: %s", response.getBody()),
    response.getStatusCode(), is(HttpURLConnection.HTTP_CREATED));

  JsonObject representation = response.getJson();

  assertThat(representation.getString("id"), is(id.toString()));
  assertThat(representation.getString("requestType"), is("Recall"));
  assertThat(representation.getString("requestDate"), is(equivalentTo(requestDate)));
  assertThat(representation.getString("itemId"), is(itemId.toString()));
  assertThat(representation.getString("requesterId"), is(requesterId.toString()));
  assertThat(representation.getString("fulfilmentPreference"), is("Hold Shelf"));
  assertThat(representation.getString("requestExpirationDate"), is("2017-07-30"));
  assertThat(representation.getString("holdShelfExpirationDate"), is("2017-08-31"));

  assertThat(representation.containsKey("item"), is(true));
  assertThat(representation.getJsonObject("item").getString("title"), is("Nod"));
  assertThat(representation.getJsonObject("item").getString("barcode"), is("565578437802"));

  assertThat(representation.containsKey("requester"), is(true));
  assertThat(representation.getJsonObject("requester").getString("lastName"), is("Jones"));
  assertThat(representation.getJsonObject("requester").getString("firstName"), is("Stuart"));
  assertThat(representation.getJsonObject("requester").getString("middleName"), is("Anthony"));
  assertThat(representation.getJsonObject("requester").getString("barcode"), is("6837502674015"));
}
 
開發者ID:folio-org,項目名稱:mod-circulation-storage,代碼行數:58,代碼來源:RequestsApiTest.java

示例13: date

private DateTime date(int month, int day) {
    return new DateTime(2012, month, day, 0, 0, DateTimeZone.UTC);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:3,代碼來源:DateDerivativeIT.java

示例14: getUtcLowercaseMaxDateTime

@Test
public void getUtcLowercaseMaxDateTime() throws Exception {
    DateTime result = client.datetimes().getUtcLowercaseMaxDateTime();
    DateTime expected = new DateTime(9999, 12, 31, 23, 59, 59, 999, DateTimeZone.UTC);
    Assert.assertEquals(expected, result);
}
 
開發者ID:Azure,項目名稱:autorest.java,代碼行數:6,代碼來源:DatetimeOperationsTests.java

示例15: getTo

@Override
public Object getTo() {
    return Double.isInfinite(((Number) to).doubleValue()) ? null : new DateTime(((Number) to).longValue(), DateTimeZone.UTC);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:4,代碼來源:InternalDateRange.java


注:本文中的org.joda.time.DateTimeZone.UTC屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。