1919package de .rwth .idsg .steve .web .api ;
2020
2121import de .rwth .idsg .steve .SteveException ;
22- import de .rwth .idsg .steve .web .LocalDateTimeEditor ;
2322import de .rwth .idsg .steve .web .api .exception .BadRequestException ;
2423import de .rwth .idsg .steve .web .api .exception .NotFoundException ;
2524import lombok .Data ;
2625import lombok .extern .slf4j .Slf4j ;
27- import org .joda .time .DateTime ;
28- import org .joda .time .LocalDateTime ;
2926import org .springframework .beans .propertyeditors .StringTrimmerEditor ;
3027import org .springframework .http .HttpStatus ;
3128import org .springframework .validation .BindException ;
3835
3936import jakarta .servlet .http .HttpServletRequest ;
4037
38+ import java .time .Instant ;
39+
4140/**
4241 * @author Sevket Goekay <sevketgokay@gmail.com>
4342 * @since 13.09.2022
@@ -49,7 +48,7 @@ public class ApiControllerAdvice {
4948 @ InitBinder
5049 public void binder (WebDataBinder binder ) {
5150 binder .registerCustomEditor (String .class , new StringTrimmerEditor (true ));
52- binder .registerCustomEditor (LocalDateTime .class , LocalDateTimeEditor . forApi ());
51+ binder .registerCustomEditor (Instant .class , new InstantEditor ());
5352 }
5453
5554 @ ExceptionHandler (BindException .class )
@@ -103,7 +102,7 @@ public ApiErrorResponse handleException(HttpServletRequest req, Exception except
103102 public static ApiErrorResponse createResponse (String url , HttpStatus status , String message ) {
104103 ApiErrorResponse result = new ApiErrorResponse ();
105104
106- result .setTimestamp (DateTime .now ());
105+ result .setTimestamp (Instant .now ());
107106 result .setStatus (status .value ());
108107 result .setError (status .getReasonPhrase ());
109108 result .setMessage (message );
@@ -114,11 +113,10 @@ public static ApiErrorResponse createResponse(String url, HttpStatus status, Str
114113
115114 @ Data
116115 public static class ApiErrorResponse {
117- private DateTime timestamp ;
116+ private Instant timestamp ;
118117 private int status ;
119118 private String error ;
120119 private String message ;
121120 private String path ;
122121 }
123-
124122}
0 commit comments