java-time

Parse LocalTime using spring expression language from application.properties

僤鯓⒐⒋嵵緔 提交于 2020-08-09 10:53:32
问题 I am trying to parse LocalTime from spring's application.properties with following code: @Value("#{ T(java.time.LocalTime).parse('${app.myDateTime}')}") private LocalTime myDateTime; in application.properties I have defined property like this: app.myDateTime=21:45:00 Error message: Failed to bind properties under 'app.my-date-time' to java.time.LocalTime: Property: app.my-date-time Value: 21:45:00 Origin: class path resource [application.properties]:44:15 Reason: failed to convert java.lang

Unable to obtain LocalTime from TemporalAccessor [duplicate]

和自甴很熟 提交于 2020-08-09 09:18:09
问题 This question already has answers here : JDK8: unable to parse LocalTime (4 answers) DateTimeParseException: Text could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor (1 answer) Convert string into LocalDateTime (4 answers) Closed 4 months ago . I am pretty new to Java 8 time, so this question probably has an obvious answer but after reading the other similar SO questions I couldn't spot any similarities which cause my issue. Here's my class: import java.time

Find standard time name for a region using Java

匆匆过客 提交于 2020-07-23 06:23:45
问题 Is there anyway to find the standard time that comes under time zone regions, for example America/New_York and America/NewJersey -> EST I am developing a REST service where the request will have region-based timezone(America/NewJersey) as a parameter and I need to find the standard time it comes under and pass it to legacy API, which only accepts 3 digit timezone(EST/MST/CST/AET). I am using Java 8 and I checked Time API, but it doesn't have any such feature/functionality. As a workaround I

Find standard time name for a region using Java

≯℡__Kan透↙ 提交于 2020-07-23 06:22:29
问题 Is there anyway to find the standard time that comes under time zone regions, for example America/New_York and America/NewJersey -> EST I am developing a REST service where the request will have region-based timezone(America/NewJersey) as a parameter and I need to find the standard time it comes under and pass it to legacy API, which only accepts 3 digit timezone(EST/MST/CST/AET). I am using Java 8 and I checked Time API, but it doesn't have any such feature/functionality. As a workaround I

Find standard time name for a region using Java

只愿长相守 提交于 2020-07-23 06:21:31
问题 Is there anyway to find the standard time that comes under time zone regions, for example America/New_York and America/NewJersey -> EST I am developing a REST service where the request will have region-based timezone(America/NewJersey) as a parameter and I need to find the standard time it comes under and pass it to legacy API, which only accepts 3 digit timezone(EST/MST/CST/AET). I am using Java 8 and I checked Time API, but it doesn't have any such feature/functionality. As a workaround I

Problem with parse a LocalDateTime using java 8

[亡魂溺海] 提交于 2020-07-22 08:55:41
问题 I have this code, it's a simple string that I want to parse it to a LocalDateTime import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; public class DateClass { /** * @param args the command line arguments */ public static void main(String[] args) { String dateRaw = "2019-05-03 7:05:03"; DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendPattern("uuuu-mm-dd HH:mm:ss").toFormatter(); LocalDateTime date=

Problem with parse a LocalDateTime using java 8

岁酱吖の 提交于 2020-07-22 08:53:46
问题 I have this code, it's a simple string that I want to parse it to a LocalDateTime import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; public class DateClass { /** * @param args the command line arguments */ public static void main(String[] args) { String dateRaw = "2019-05-03 7:05:03"; DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendPattern("uuuu-mm-dd HH:mm:ss").toFormatter(); LocalDateTime date=

Java 8 DateTimeFormatter for month in all CAPS not working [duplicate]

萝らか妹 提交于 2020-07-15 06:55:30
问题 This question already has an answer here : How to handle upper or lower case in JSR 310? [duplicate] (1 answer) Closed 4 years ago . I'm trying to parse date time string to LocalDateTime. However if I send month with all caps its thorwning an error, is there any workaround. Here is the below code @Test public void testDateFormat(){ DateTimeFormatter formatter= DateTimeFormatter.ofPattern("dd-MMM-yyyy HH:mm:ss"); LocalDateTime dateTime = LocalDateTime.parse("04-NOV-2015 16:00:00", formatter);

Migration from org.joda.time.Interval in Spring Boot

柔情痞子 提交于 2020-07-10 06:34:09
问题 I used to apply org.joda.time.Interval to represent a time interval with fixed start and end times (different from a duration which is independent from specific times) to exchange via REST and store energy schedules in a Spring Boot server application (2.2.2.RELEASE). I tried different ways to store a org.joda.time.Interval field of an object via JPA/Hibernate: jadira (7.0.0.CR1) with annotation above the field definition ( @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentInterval

Migration from org.joda.time.Interval in Spring Boot

坚强是说给别人听的谎言 提交于 2020-07-10 06:33:33
问题 I used to apply org.joda.time.Interval to represent a time interval with fixed start and end times (different from a duration which is independent from specific times) to exchange via REST and store energy schedules in a Spring Boot server application (2.2.2.RELEASE). I tried different ways to store a org.joda.time.Interval field of an object via JPA/Hibernate: jadira (7.0.0.CR1) with annotation above the field definition ( @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentInterval