Java Code Examples for java.time.LocalDateTime.minusWeeks()

The following are Jave code examples for showing how to use minusWeeks() of the java.time.LocalDateTime class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: cakes   File: LocalDateTimeDemo.java   Source Code and License Vote up 4 votes
/**
 * 时间计算,减法操作
 */
@Test
public void testClac(){
    LocalDateTime ldt = LocalDateTime.now();

    System.out.println(ldt);

    // 减: 天
    LocalDateTime days = ldt.minusDays(1);
    System.out.println("day: " + days);

    // 减: 小时
    LocalDateTime hours = ldt.minusHours(1);
    System.out.println("hours: " + hours);

    // 减: 分钟
    LocalDateTime minutes = ldt.minusMinutes(1);
    System.out.println("minutes: " + minutes);

    // 减: 月
    LocalDateTime months = ldt.minusMonths(1);
    System.out.println("months: " + months);

    // 减: 纳秒
    LocalDateTime nanos = ldt.minusNanos(1);
    System.out.println("nanos: " + nanos);

    // 减: 秒
    LocalDateTime seconds = ldt.minusSeconds(1);
    System.out.println("seconds: " + seconds);

    // 减: 周
    LocalDateTime weeks = ldt.minusWeeks(1);
    System.out.println("weeks: " + weeks);

    // 减: 年
    LocalDateTime years = ldt.minusYears(1);
    System.out.println("years: " + years);

    System.out.println(ldt);
}