Vacation timer label #3

Merged
redphoenix9123 merged 2 commits from vacation-timer-label into master 2022-08-03 02:47:36 +00:00
2 changed files with 6 additions and 8 deletions
Showing only changes of commit a2a91cd86c - Show all commits

View file

@ -2,16 +2,15 @@ package com.synergyhelix.countdown;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.*;
@RestController
public class CountdownController {
@ -25,8 +24,7 @@ public class CountdownController {
}
private BufferedImage createImage() throws IOException {
final BufferedImage image = ImageIO.read(new URL(
"https://media-cdn.tripadvisor.com/media/photo-s/04/18/a2/85/chicago.jpg"));
final BufferedImage image = ImageIO.read(getClass().getResourceAsStream("/chicago.jpg"));
Graphics g = image.getGraphics();
@ -48,9 +46,9 @@ public class CountdownController {
}
private String calculateTimeUntilThing() {
LocalDateTime trip = LocalDateTime.parse("2022-08-13T09:00:00");
ZonedDateTime trip = ZonedDateTime.of(LocalDateTime.parse("2022-08-13T13:00:00"), ZoneId.of("UTC"));
Duration duration = Duration.between(LocalDateTime.now(), trip);
Duration duration = Duration.between(Instant.now(), trip);
return DurationFormatUtils.formatDuration(duration.toMillis(), "dd'D' HH'H' mm'M' ss'S'", true);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB