jodatime

How to check if a list of intervals (Joda-Time) fully covers a month in Java

蹲街弑〆低调 提交于 2019-12-21 17:37:05
问题 I'm using Joda-Time library in Java to keep track a list of time intervals. I want to check if a list of Interval objects fully covers every minute of a month. There's about 30 intervals of varying length from a few hours to a few days. I thought a cheap way to do this is to sort the list of intervals by start time, then successively check if there is a break between the intervals within the range of the month. If yes, then the month is not fully covered. I'm stuck on the first part, sorting

migrate from Joda time library to Java time(Java 8)

筅森魡賤 提交于 2019-12-21 17:31:34
问题 I am trying to migrate from Joda time library to Java time (Java 8). I am unable to find equivalent of ISODateTimeFormat.dateOptionalTimeParser() in java.time Joda ISO formatter has nice parsers: ISODateTimeFormat.dateTimeParser() : generic - selects parser based on string parsed. Similarly: ISODateTimeFormat.dateOptionalTimeParser() . I am finding it difficult to change Joda time to java.time. Can some one guide me? example: String dateTimeString = "2015-01-01T12:29:22+00:00"; String

Getting nominative month name in jodaTime

感情迁移 提交于 2019-12-21 10:51:22
问题 I need to get month name according to it's number in different Locales . To do this I create a DateTime (or YearMonth , doesn't matter) Object and get its monthOfYear Property: YearMonth md = new YearMonth(1992, month); System.out.println(md.monthOfYear().getAsText(new Locale("ru"))); The thing is that works fine for English language, because Nominative and Genitive names are the same, but for other languages it returns only Genitive, which is not what I need. How to get Nominative month name

Getting nominative month name in jodaTime

六眼飞鱼酱① 提交于 2019-12-21 10:50:41
问题 I need to get month name according to it's number in different Locales . To do this I create a DateTime (or YearMonth , doesn't matter) Object and get its monthOfYear Property: YearMonth md = new YearMonth(1992, month); System.out.println(md.monthOfYear().getAsText(new Locale("ru"))); The thing is that works fine for English language, because Nominative and Genitive names are the same, but for other languages it returns only Genitive, which is not what I need. How to get Nominative month name

Getting nominative month name in jodaTime

守給你的承諾、 提交于 2019-12-21 10:50:10
问题 I need to get month name according to it's number in different Locales . To do this I create a DateTime (or YearMonth , doesn't matter) Object and get its monthOfYear Property: YearMonth md = new YearMonth(1992, month); System.out.println(md.monthOfYear().getAsText(new Locale("ru"))); The thing is that works fine for English language, because Nominative and Genitive names are the same, but for other languages it returns only Genitive, which is not what I need. How to get Nominative month name

Convert Joda-Time DateTime - ISO 8601 format date to another date format

爱⌒轻易说出口 提交于 2019-12-20 12:38:57
问题 Inside my Java app I am using Joda-Time to convert the app user entered date from MM/dd/yyyy to ISO 8601 format in order to save it in DB. Can someone please tell me how I can convert the ISO 8601 date back to MM/dd/yyyy format using Joda-Time? My code convert user date to ISO 8601 date format: String date1 = "05/05/2013"; DateTimeFormatter parser1 = DateTimeFormat.forPattern("MM/dd/yyyy"); DateTime dateTimeObj1 = DateTime.parse(date1,parser1); DateTimeFormatter isoDateFormat =

How to check a DateTime is an occurence of recurring event using Joda Time?

不想你离开。 提交于 2019-12-20 05:10:22
问题 I've a DateTime that represent the beginning of a recurring event. A Days (daily period) will represent the recurring period. I assume that this recurring event will never stop. from = "2013-06-27" period = 3 days nextOccurence will be "2013-06-30", "2013-07-03", "2013-07-06", and so on. "2013-07-03" is an occurence but "2013-07-04" isn't an occurence. I would like to know what is the best way in term of performance to determine if a DateTime is an occurence of the recurring event? In the

convert one time zone to another using joda time

烈酒焚心 提交于 2019-12-20 01:09:56
问题 there is a form having a drop down for country ,user will select the country ,then there is a drop down for time zone ,user will select the time zone which are available in country selected by the user.Then user will enter the local date( eg: 26-Dec-2014) and time( 23:11)(24 hours time) this entered date and time is for the selected country and time zone. now i have to convert this date and time to GMT time zone. how can i do this using joda time how the daylight saving time(DST) will be

Convert String to Joda LocalTime format (HH:mm:ss) and Remove milliseconds

社会主义新天地 提交于 2019-12-19 18:24:06
问题 DateTimeFormatter fmt = DateTimeFormat.forPattern("HH:mm:ss"); LocalTime localTime = fmt.parseLocalTime("02:51:20"); System.out.println("LocalTime: "+localTime); I need only 02:51:20 but it outputs as 02:51:20.000. Is there any way that I can remove the .000 (milliseconds) from the output. 回答1: Yes - you just need to format when you print out. Currently you're just using the default toString() representation. If you're happy with the formatter you've already got, you can just use: System.out

Joda-Time: Get first/second/last sunday of month

岁酱吖の 提交于 2019-12-19 17:44:31
问题 In plain Java, I have this code to get the last Sunday of the month. Calendar getNthOfMonth(int n, int day_of_week, int month, int year) { Calendar compareDate = Date(1, month, year); compareDate.set(DAY_OF_WEEK, day_of_week); compareDate.set(DAY_OF_WEEK_IN_MONTH, n); return compareDate; } // Usage Calendar lastSundayOfNovember = getNthOfMonth(-1, SUNDAY, NOVEMBER, 2012) What is a clean and elegant way to achieve the same result using Joda-Time? 回答1: public class Time { public static void