Java Code Examples for java.time.ZonedDateTime#minusWeeks()

The following examples show how to use java.time.ZonedDateTime#minusWeeks() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKZonedDateTime.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(1);
    assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100));
}
 
Example 2
Source File: TCKZonedDateTime.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(1);
    assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100));
}
 
Example 3
Source File: TCKZonedDateTime.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks_zero() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(0);
    assertEquals(test, base);
}
 
Example 4
Source File: TCKZonedDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(1);
    assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100));
}
 
Example 5
Source File: TCKZonedDateTime.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks_zero() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(0);
    assertEquals(test, base);
}
 
Example 6
Source File: TCKZonedDateTime.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(1);
    assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100));
}
 
Example 7
Source File: TCKZonedDateTime.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void test_minusWeeks_zero() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(0);
    assertEquals(test, base);
}
 
Example 8
Source File: TCKZonedDateTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(1);
    assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100));
}
 
Example 9
Source File: TCKZonedDateTime.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks_zero() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(0);
    assertEquals(test, base);
}
 
Example 10
Source File: TCKZonedDateTime.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(1);
    assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100));
}
 
Example 11
Source File: TCKZonedDateTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks_zero() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(0);
    assertEquals(test, base);
}
 
Example 12
Source File: TCKZonedDateTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(1);
    assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100));
}
 
Example 13
Source File: TCKZonedDateTime.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks_zero() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(0);
    assertEquals(test, base);
}
 
Example 14
Source File: TCKZonedDateTime.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(1);
    assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100));
}
 
Example 15
Source File: TCKZonedDateTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks_zero() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(0);
    assertEquals(test, base);
}
 
Example 16
Source File: TCKZonedDateTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(1);
    assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100));
}
 
Example 17
Source File: TCKZonedDateTime.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks_zero() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(0);
    assertEquals(test, base);
}
 
Example 18
Source File: TCKZonedDateTime.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(1);
    assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100));
}
 
Example 19
Source File: TCKZonedDateTime.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_minusWeeks_zero() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusWeeks(0);
    assertEquals(test, base);
}
 
Example 20
Source File: TvMazeUtils.java    From drftpd with GNU General Public License v2.0 4 votes vote down vote up
private static String calculateAge(ZonedDateTime epDate) {
    // Get now
    ZonedDateTime now = ZonedDateTime.now();

    // Get the (positive) time between now and epData
    ZonedDateTime t1 = now;
    ZonedDateTime t2 = epDate;
    if (epDate.isBefore(now)) {
        t1 = epDate;
        t2 = now;
    }

    String age = "";
    long years = ChronoUnit.YEARS.between(t1, t2);
    if (years > 0) {
        age += years+"y";
        t2 = t2.minusYears(years);
    }

    long months = ChronoUnit.MONTHS.between(t1, t2);
    if (months > 0) {
        age += months+"m";
        t2 = t2.minusMonths(months);
    }

    long weeks = ChronoUnit.WEEKS.between(t1, t2);
    if (weeks > 0) {
        age += weeks+"w";
        t2 = t2.minusWeeks(weeks);
    }

    long days = ChronoUnit.DAYS.between(t1, t2);
    if (days > 0) {
        age += days+"d";
        t2 = t2.minusDays(days);
    }
    boolean spaceadded = false;

    long hours = ChronoUnit.HOURS.between(t1, t2);
    if (hours > 0) {
        age += " "+hours+"h";
        spaceadded = true;
        t2 = t2.minusHours(hours);
    }

    long minutes = ChronoUnit.MINUTES.between(t1, t2);
    if (minutes > 0) {
        if (!spaceadded) { age += " ";  }
        age += minutes+"m";
    }
    if (age.length() == 0) { age = "0"; }

    return age;
}