Vacation timer label #3
2 changed files with 6 additions and 8 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
BIN
src/main/resources/chicago.jpg
Normal file
BIN
src/main/resources/chicago.jpg
Normal file
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Loading…
Reference in a new issue