• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 11292419862

11 Oct 2024 12:34PM UTC coverage: 66.152% (-0.4%) from 66.509%
11292419862

push

github

web-flow
devonfw/ide-urls#17: fix UrlUpdater to auto-remove broken URLs and allow self-repair (#681)

2381 of 3940 branches covered (60.43%)

Branch coverage included in aggregate %.

6193 of 9021 relevant lines covered (68.65%)

3.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
cli/src/main/java/com/devonfw/tools/ide/util/DateTimeUtil.java
1
package com.devonfw.tools.ide.util;
2

3
import java.time.Duration;
4
import java.time.Instant;
5
import java.time.LocalDateTime;
6
import java.time.format.DateTimeFormatter;
7
import java.time.format.DateTimeFormatterBuilder;
8

9
/**
10
 * Utility class for operations on data and time (java.time).
11
 */
12
public final class DateTimeUtil {
13

14
  private static final DateTimeFormatter DATE_FORMATTER = new DateTimeFormatterBuilder().appendPattern("YYYY-MM-dd")
5✔
15
      .toFormatter();
2✔
16

17
  private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder().appendPattern("HH-mm-ss")
6✔
18
      .toFormatter();
2✔
19

20
  // construction forbidden
21
  private DateTimeUtil() {
22

23
  }
24

25
  /**
26
   * @param start the first {@link Instant}.
27
   * @param end the second {@link Instant}.
28
   * @return {@code true} if the first {@link Instant} is after the second.
29
   */
30
  public static boolean isAfter(Instant start, Instant end) {
31

32
    if ((start == null) || (end == null)) {
4!
33
      return false;
×
34
    }
35
    return start.isAfter(end);
4✔
36
  }
37

38
  /**
39
   * @param start the first {@link Instant}.
40
   * @param end the second {@link Instant}.
41
   * @return {@code true} if the first {@link Instant} is before the second.
42
   */
43
  public static boolean isBefore(Instant start, Instant end) {
44

45
    if ((start == null) || (end == null)) {
4!
46
      return false;
×
47
    }
48
    return start.isBefore(end);
4✔
49
  }
50

51
  /**
52
   * @param start the start {@link Instant}.
53
   * @param end the end {@link Instant}.
54
   * @param duration the {@link Duration} to compare to.
55
   * @return {@code 0} if the {@link Duration} from {@code start} to {@code end} is equal to the given {@link Duration}, negative value if less, positive value
56
   *     is greater and {@code null} if one of the given values was {@code null}.
57
   */
58
  public static Integer compareDuration(Instant start, Instant end, Duration duration) {
59

60
    if ((start == null) || (end == null) || (duration == null)) {
6!
61
      return null;
×
62
    }
63
    Duration delta = Duration.between(start, end);
4✔
64
    return Integer.valueOf(delta.compareTo(duration));
5✔
65
  }
66

67
  /**
68
   * @param temporal the {@link LocalDateTime} to format as date.
69
   * @return the {@link LocalDateTime} formatted as date in the format YYYY-MM-dd.
70
   */
71
  public static String formatDate(LocalDateTime temporal) {
72

73
    return temporal.format(DATE_FORMATTER);
4✔
74
  }
75

76
  /**
77
   * @param temporal the {@link LocalDateTime} to format as time.
78
   * @return the {@link LocalDateTime} formatted as time in the format HH-mm-ss.
79
   */
80
  public static String formatTime(LocalDateTime temporal) {
81

82
    return temporal.format(TIME_FORMATTER);
4✔
83
  }
84

85
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc