jodatime

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

孤人 提交于 2020-02-22 08:09:31
问题 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:09:28
问题 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:09:22
问题 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 parse date time string in India timezone using Joda date time API 2.10.1? [duplicate]

坚强是说给别人听的谎言 提交于 2020-02-16 10:41:52
问题 This question already has answers here : Joda DateTimeFormatter.parseDateTime is failing for General time zone('z') (1 answer) how to parse output of new Date().toString() (3 answers) Closed 8 days ago . import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; public class Main { public static void main(String[] args) { DateTimeFormatter utcFormatter = DateTimeFormat.forPattern("EEE MMM dd HH

Joda DateTimeFormatter.parseDateTime is failing for General time zone('z')

丶灬走出姿态 提交于 2020-02-10 19:33:34
问题 Confused with the use of General time zone('z'). Joda is failing in below sample code. Can somebody help me to understand why the behavior is like this? How can I parse a date in differnt timezone using this format in Joda? public static void main(String[] args) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z"); System.out.println(sdf.parse("2019.09.17 AD at 15:29:00 IST")); DateTimeFormatter pattern = DateTimeFormat.forPattern("yyyy.MM.dd G

Using Groovy(or Java) how can I convert a org.joda.time.LocalDateTime to a java.util.date?

ε祈祈猫儿з 提交于 2020-02-02 11:12:33
问题 Using Groovy (or Java) how can I convert a org.joda.time.LocalDateTime to a java.util.Date ? import org.joda.time.* Calendar cal = Calendar.instance cal.set(Calendar.DATE, 1) cal.set(Calendar.HOUR, 0) cal.set(Calendar.MINUTE, 0) cal.set(Calendar.SECOND, 0) cal.set(Calendar.MILLISECOND, 0) Date startOfTheMonth = cal.time LocalDateTime localDateTime = new LocalDateTime() localDateTime = localDateTime.withDayOfMonth(1) localDateTime = localDateTime.withTime(0,0,0,0) localDateTime.minusMonths(6)

Good way to convert integer YYYYMMDD into java.util.Date with local time zone

老子叫甜甜 提交于 2020-01-30 13:09:25
问题 I understand this question could look like FAQ subject but critical things here is time zone and performance. I have integer YYYYMMDD date (20150131 is example). Here is good 'almost working' solution: import org.joda.time.DateTime; import java.util.Date; // ... public Date extract(final int intDate) { Date result = null; try { result = new DateTime( intDate / 10000, (intDate / 100) % 100, intDate % 100, 0, 0, 0, 0).toDate(); } catch (final IllegalArgumentException e) { // Log failure }

Good way to convert integer YYYYMMDD into java.util.Date with local time zone

依然范特西╮ 提交于 2020-01-30 13:09:13
问题 I understand this question could look like FAQ subject but critical things here is time zone and performance. I have integer YYYYMMDD date (20150131 is example). Here is good 'almost working' solution: import org.joda.time.DateTime; import java.util.Date; // ... public Date extract(final int intDate) { Date result = null; try { result = new DateTime( intDate / 10000, (intDate / 100) % 100, intDate % 100, 0, 0, 0, 0).toDate(); } catch (final IllegalArgumentException e) { // Log failure }

How to get time with respect to another timezone in android [duplicate]

偶尔善良 提交于 2020-01-29 02:31:12
问题 This question already has answers here : Timezone conversion (10 answers) Closed 5 years ago . I want to create an alarm application for FIFA 2014 world cup matches in which i have a server which stores the date and time for the matches in Brazil/Acre and my client is an android application and an android device may have any of the possible timezone so the my problem is i want to convert the Brazil/Acre timing to the local android device timing with different timezone and after lot of googled

How to get time with respect to another timezone in android [duplicate]

陌路散爱 提交于 2020-01-29 02:31:08
问题 This question already has answers here : Timezone conversion (10 answers) Closed 5 years ago . I want to create an alarm application for FIFA 2014 world cup matches in which i have a server which stores the date and time for the matches in Brazil/Acre and my client is an android application and an android device may have any of the possible timezone so the my problem is i want to convert the Brazil/Acre timing to the local android device timing with different timezone and after lot of googled