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


Java ZonedDateTime.minusMinutes方法代码示例

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


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

示例1: getTestParameters

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Gets the unit test parameters.
 *
 * @return  Test parameter data.
 * @throws Exception if there is an exception getting the test parameters.
 */
@Parameters
public static Collection<Object[]> getTestParameters() throws Exception {
    final Collection<Object[]> params = new ArrayList<>();

    final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
    final ZonedDateTime twoHoursAgo = now.minusHours(2);
    final ZonedDateTime oneHourAgo = now.minusHours(1);
    final ZonedDateTime halfHourAgo = now.minusMinutes(30);
    final X500Principal issuer = new X500Principal("CN=CAS");

    // Test case #1
    // Expect expired for zero leniency on CRL expiring 1ms ago
    final ThresholdExpiredCRLRevocationPolicy zeroThreshold = new ThresholdExpiredCRLRevocationPolicy(0);
    params.add(new Object[] {
            zeroThreshold,
            new MockX509CRL(issuer, DateTimeUtils.dateOf(oneHourAgo), DateTimeUtils.dateOf(now.minusSeconds(1))),
            new ExpiredCRLException("CN=CAS", ZonedDateTime.now(ZoneOffset.UTC)),
    });

    // Test case #2
    // Expect expired for 1h leniency on CRL expired 1 hour 1ms ago
    final ThresholdExpiredCRLRevocationPolicy oneHourThreshold = new ThresholdExpiredCRLRevocationPolicy(3600);
    params.add(new Object[] {
            oneHourThreshold,
            new MockX509CRL(issuer, DateTimeUtils.dateOf(twoHoursAgo), DateTimeUtils.dateOf(oneHourAgo.minusSeconds(1))),
            new ExpiredCRLException("CN=CAS", ZonedDateTime.now(ZoneOffset.UTC)),
    });

    // Test case #3
    // Expect valid for 1h leniency on CRL expired 30m ago
    params.add(new Object[] {
            oneHourThreshold,
            new MockX509CRL(issuer, DateTimeUtils.dateOf(twoHoursAgo), DateTimeUtils.dateOf(halfHourAgo)),
            null,
    });

    return params;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:45,代码来源:ThresholdExpiredCRLRevocationPolicyTests.java

示例2: test_minusMinutes_minutes

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void test_minusMinutes_minutes() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusMinutes(30);
    assertEquals(test, ZonedDateTime.of(ldt.minusMinutes(30), ZONE_0100));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKZonedDateTime.java

示例3: parseTest

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void parseTest() throws IOException{

    ObjectMapper mapper = new ObjectMapper();
    Instant now = Instant.ofEpochSecond(System.currentTimeMillis() / 1000);
    ZonedDateTime auth_time = ZonedDateTime.ofInstant(now, ZoneId.systemDefault());
    ZonedDateTime iat = ZonedDateTime.from(auth_time);
    ZonedDateTime exp = ZonedDateTime
      .ofInstant(now, ZoneId.systemDefault())
      .plusMinutes(30);
    ZonedDateTime nbf = exp.minusMinutes(1);
    String jsonToken = "{\n" + "    \"exp\": " + exp.toEpochSecond() + ",\n" + "    \"nbf\": " + nbf.toEpochSecond() + ",\n" + "    \"ver\": \"1.0\",\n" + "    \"iss\": \"https://login.microsoftonline.com/11111111-1111-1111-1111-111111111111/v2.0/\",\n" + "    \"acr\": \"b2c_1_what-you-named-the-policy\",\n" + "    \"sub\": \"Not supported currently. Use oid claim.\",\n" + "    \"aud\": \"11111111-1111-1111-1111-111111111111\",\n" + "    \"nonce\": \"11111111-1111-1111-1111-111111111111\",\n" + "    \"iat\": " + iat.toEpochSecond() + ",\n" + "    \"auth_time\": " + auth_time.toEpochSecond() + ",\n" + "    \"oid\": \"11111111-1111-1111-1111-111111111111\",\n" + "    \"given_name\": \"One Punch\",\n" + "    \"family_name\": \"Saitama\",\n" + "    \"emails\": [\n" + "       \"[email protected]\"\n" + "    ]\n" + "}";

    BlueWebToken token = mapper.readValue(jsonToken, BlueWebToken.class);
    assertEquals(token.getExpiration(), exp);
    assertEquals(token.getNotBefore(), nbf);
    assertEquals(token.getVersion(), "1.0");
    assertEquals(token.getIssuer(), "https://login.microsoftonline.com/11111111-1111-1111-1111-111111111111/v2.0/");
    assertEquals(token.getAuthContextReference(), "b2c_1_what-you-named-the-policy");
    assertEquals(token.getSubject(), "Not supported currently. Use oid claim.");
    assertEquals(token.getAudience(), "11111111-1111-1111-1111-111111111111");
    assertEquals(token.getNonce(), "11111111-1111-1111-1111-111111111111");
    assertEquals(token.getIssuedAt(), iat);
    assertEquals(token.getAuthTime(), auth_time);
    assertEquals(token.getObjectId(), "11111111-1111-1111-1111-111111111111");
    assertEquals(token.getFirstName(), "One Punch");
    assertEquals(token.getLastName(), "Saitama");
    assertEquals(token.getFirstEmail(), "[email protected]");
}
 
开发者ID:Xitikit,项目名称:xitikit-blue,代码行数:30,代码来源:BlueWebTokenTest.java

示例4: parseTimeString

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * evaluates a announcement override 'time string' into a definite ZonedDateTime object
 * @param time 'time string'
 * @param se ScheduleEntry the override resides on
 * @return ZonedDateTime for announcement override, or null if un-parsable
 */
public static ZonedDateTime parseTimeString(String time, ScheduleEntry se)
{
    time = time.toUpperCase();  // all caps

    // determine basis for the announcement time
    ZonedDateTime announcementTime;
    if(time.startsWith("START"))
    {
        time = time.replace("START", "");
        announcementTime = se.getStart();
    }
    else if(time.startsWith("END"))
    {
        time = time.replace("END", "");
        announcementTime = se.getEnd();
    }
    else
    {
        return null;
    }

    // determine if offset is positive or negative
    boolean positive;
    if(time.startsWith("+"))
    {
        time = time.replace("+", "");
        positive = true;
    }
    else if(time.startsWith("-"))
    {
        time = time.replace("-", "");
        positive = false;
    }
    else
    {
        return announcementTime;
    }

    // parse out the time offset
    Integer minutes = time.replaceAll("[^\\d]", "").isEmpty() ?
            0 : Integer.parseInt(time.replaceAll("[^\\d]", ""));
    if (minutes != 0)
    {
        switch(time.charAt(time.length()-1))
        {
            case 'H':
                minutes = minutes*60;
                break;
            case 'D':
                minutes = 60*24;
                break;
        }
    }

    // add offset to the time and return
    if(positive) return announcementTime.plusMinutes(minutes);
    else return announcementTime.minusMinutes(minutes);
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:65,代码来源:ParsingUtilities.java


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