Updated time calc to UTC and made base image local
This commit is contained in:
parent
e5884e0a69
commit
c6fe62ca1f
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.apache.commons.lang3.time.DurationFormatUtils;
|
||||||
import org.springframework.http.MediaType;
|
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 javax.imageio.ImageIO;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.time.*;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class CountdownController {
|
public class CountdownController {
|
||||||
|
|
@ -25,8 +24,7 @@ public class CountdownController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private BufferedImage createImage() throws IOException {
|
private BufferedImage createImage() throws IOException {
|
||||||
final BufferedImage image = ImageIO.read(new URL(
|
final BufferedImage image = ImageIO.read(getClass().getResourceAsStream("/chicago.jpg"));
|
||||||
"https://media-cdn.tripadvisor.com/media/photo-s/04/18/a2/85/chicago.jpg"));
|
|
||||||
|
|
||||||
Graphics g = image.getGraphics();
|
Graphics g = image.getGraphics();
|
||||||
|
|
||||||
|
|
@ -44,9 +42,9 @@ public class CountdownController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String calculateTimeUntilThing() {
|
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);
|
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.
|
After Width: | Height: | Size: 31 KiB |
Loading…
Reference in a new issue