jodatime

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

DateTimeFormatter weekday seems off by one

こ雲淡風輕ζ 提交于 2020-06-10 02:35:08
问题 I'm porting an existing application from Joda-Time to Java 8 java.time . I ran into a problem where parsing a date/time string that contains a 'day of week' value triggered an exception in my unit tests. When parsing: 2016-12-21 20:50:25 Wednesday December +0000 3 using format: yyyy'-'MM'-'dd' 'HH':'mm':'ss' 'EEEE' 'MMMM' 'ZZ' 'e I get: java.time.format.DateTimeParseException: Text '2016-12-21 20:50:25 Wednesday December +0000 3' could not be parsed: Conflict found: Field DayOfWeek 3 differs

Android in date write today yesterday 2 days ago like that

喜夏-厌秋 提交于 2020-06-08 05:38:06
问题 I need to print date like today,Yesterday,2 days ago like that for that i have done I am getting date like : String date1 = "Thu Nov 13 19:01:25 GMT+05:30 2014"; calling like str=get_userTime(date1); private String get_userTime(String usertime) { Date d = null; // String datee = "Thu Nov 13 19:01:25 GMT+05:30 2014"; String datee = usertime; SimpleDateFormat inputFormat = new SimpleDateFormat( "EE MMM dd HH:mm:ss zz yyy"); try { d = inputFormat.parse(datee); } catch (java.text.ParseException e

Android in date write today yesterday 2 days ago like that

落花浮王杯 提交于 2020-06-08 05:38:06
问题 I need to print date like today,Yesterday,2 days ago like that for that i have done I am getting date like : String date1 = "Thu Nov 13 19:01:25 GMT+05:30 2014"; calling like str=get_userTime(date1); private String get_userTime(String usertime) { Date d = null; // String datee = "Thu Nov 13 19:01:25 GMT+05:30 2014"; String datee = usertime; SimpleDateFormat inputFormat = new SimpleDateFormat( "EE MMM dd HH:mm:ss zz yyy"); try { d = inputFormat.parse(datee); } catch (java.text.ParseException e

Get the next LocalDateTime for a given day of week

℡╲_俬逩灬. 提交于 2020-05-23 06:01:24
问题 I want to create instance of LocalDateTime at the date/time of the next (for example) Monday. Is there any method in Java Time API, or should I make calculations how many days are between current and destination dates and then use LocalDateTime.of() method? 回答1: There is no need to do any calculations by hand. You can adjust a given date with an adjuster with the method LocalDateTime.with(adjuster). There is a built-in adjuster for the next day of the week: TemporalAdjusters.next(dayOfWeek):

Is there a class for encoding a local time of week in Java?

a 夏天 提交于 2020-05-13 04:35:00
问题 I'm wanting to create a schedule that wraps around week by week. Because the schedule is the same from one week to the next, the only information I need to store is the day of the week, and the time it occurs. eg. Monday 2:30pm . The actual date isn't important, nor is time zone. So far I've been writing my code with the day and time separate, using the DayOfWeek enum and the LocalTime type to work with times. But I've started to run into issues with using two variables to manage time instead

Is there a class for encoding a local time of week in Java?

末鹿安然 提交于 2020-05-13 04:34:27
问题 I'm wanting to create a schedule that wraps around week by week. Because the schedule is the same from one week to the next, the only information I need to store is the day of the week, and the time it occurs. eg. Monday 2:30pm . The actual date isn't important, nor is time zone. So far I've been writing my code with the day and time separate, using the DayOfWeek enum and the LocalTime type to work with times. But I've started to run into issues with using two variables to manage time instead

How to send parameters to a reference method in a stream (java 8)?

我与影子孤独终老i 提交于 2020-02-22 08:12:21
问题 I have a list of activities(Activity) and I want to determine a data structure of the form Map(String, DateTime) (not Duration or Period; DateTime it's a must) that maps. For each activity the total duration computed over the monitoring period. The class Activity has: activityLabel(String) , startTime(DateTime) , endTime(DateTime) . I use joda time. This is what I have done: Map<String, DateTime> durations = activities.stream().collect(Collectors.toMap( it -> it.activityLabel, it ->new

How to send parameters to a reference method in a stream (java 8)?

百般思念 提交于 2020-02-22 08:10:13
问题 I have a list of activities(Activity) and I want to determine a data structure of the form Map(String, DateTime) (not Duration or Period; DateTime it's a must) that maps. For each activity the total duration computed over the monitoring period. The class Activity has: activityLabel(String) , startTime(DateTime) , endTime(DateTime) . I use joda time. This is what I have done: Map<String, DateTime> durations = activities.stream().collect(Collectors.toMap( it -> it.activityLabel, it ->new

How to send parameters to a reference method in a stream (java 8)?

久未见 提交于 2020-02-22 08:10:11
问题 I have a list of activities(Activity) and I want to determine a data structure of the form Map(String, DateTime) (not Duration or Period; DateTime it's a must) that maps. For each activity the total duration computed over the monitoring period. The class Activity has: activityLabel(String) , startTime(DateTime) , endTime(DateTime) . I use joda time. This is what I have done: Map<String, DateTime> durations = activities.stream().collect(Collectors.toMap( it -> it.activityLabel, it ->new