jodatime

Find DST transition timestamp with java.util.TimeZone

让人想犯罪 __ 提交于 2020-01-03 16:46:17
问题 Is it possible to get the previous and next DST transition timestamp with the Java Calendar/Date/TimeZone API? With Joda-Time I can write: DateMidnight today = new DateMidnight(2009, 2, 24); DateTimeZone zone = today.getZone(); DateTime previousTransition = new DateTime(zone.previousTransition(today.getMillis())); // 2008-10-26T02:59:59.999+02:00 for Europe/Berlin System.out.println(previousTransition); DateTime nextTransition = new DateTime(zone.nextTransition(today.getMillis())); // 2009-03

Find DST transition timestamp with java.util.TimeZone

好久不见. 提交于 2020-01-03 16:46:02
问题 Is it possible to get the previous and next DST transition timestamp with the Java Calendar/Date/TimeZone API? With Joda-Time I can write: DateMidnight today = new DateMidnight(2009, 2, 24); DateTimeZone zone = today.getZone(); DateTime previousTransition = new DateTime(zone.previousTransition(today.getMillis())); // 2008-10-26T02:59:59.999+02:00 for Europe/Berlin System.out.println(previousTransition); DateTime nextTransition = new DateTime(zone.nextTransition(today.getMillis())); // 2009-03

Java ZonedDateTime to Instant conversion

情到浓时终转凉″ 提交于 2020-01-02 05:14:08
问题 I am planning to convert ZonedDateTime to instant as per the below logic. Say, I am in PST timeZone and the current time is 11A.M. If I convert now( no daylight saving as of today March 04 2018) and the toInstant will be 7P.M. For the same 11 A.M, the toInstant will return 6 P.M as of April 04 2018 as daylight saving will be observed. So, The below code returns correctly. ZonedDateTime dateTime = ZonedDateTime.now(); --->>> March 04th 2018 at 11 A.M PST dateTime.plusMonths(1).toInstant(); -->

Joda Time, Get week days [duplicate]

徘徊边缘 提交于 2020-01-01 09:47:22
问题 This question already has answers here : joda time - add weekdays to date (4 answers) Closed 6 years ago . How to make the local date count only week date? For example LocalDate date = new LocalDate(); date.plusDays(10); //it returns plus days including sat and sun as 2013-03-21 //i am looking for a way date.plusDays(10); //should return as 2013-03-26 I am look for a way to remove the weekends? 回答1: Use the getDayOfWeek() method. Return will be as follows. Inorder to get only week days.. you

Joda Time, Get week days [duplicate]

冷暖自知 提交于 2020-01-01 09:47:12
问题 This question already has answers here : joda time - add weekdays to date (4 answers) Closed 6 years ago . How to make the local date count only week date? For example LocalDate date = new LocalDate(); date.plusDays(10); //it returns plus days including sat and sun as 2013-03-21 //i am looking for a way date.plusDays(10); //should return as 2013-03-26 I am look for a way to remove the weekends? 回答1: Use the getDayOfWeek() method. Return will be as follows. Inorder to get only week days.. you

How to handle JodaTime's and Android's timezone database differences?

删除回忆录丶 提交于 2020-01-01 05:43:09
问题 I want to extend a discussion I started on the Reddit Android Dev community yesterday with a new question: How do you manage an up-to-date timezone database shipped with your app using the JodaTime library on a device that has outdated timezone information? The problem The specific issue at hand relates to a particular timezone, "Europe/Kaliningrad". And I can reproduce the problem: On an Android 4.4 device, if I manually set its time zone to the above, calling new DateTime() will set this

Using Joda-Time to get UTC offset for a given date and timezone

会有一股神秘感。 提交于 2020-01-01 04:12:09
问题 I have dates in the format 20Jan2013, 08Aug2012 etc, with their own specific timezones. So for example, 20Jan2013 might have a timezone ID of Australia/Melbourne, and 08Aug2012 might have an ID of Europe/London. What I want to do is, based on these timezones and the dates, calculate the UTC offset for that timezone on the given date. I've come up with this so far: DateTimeFormatter dtf = DateTimeFormat.forPattern("ZZ"); DateTimeFormatter dtf1 = DateTimeFormat.forPattern("ddMMMYYYY");

Pattern String from a joda-time DateTimeFormatter?

我的梦境 提交于 2019-12-31 21:43:46
问题 Is it possible to get the pattern string from a joda-time DateTimeFormatter? DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMdd"); String originalPattern = formatter. ??? 回答1: Joda Time does not provide a way to get the original pattern from a DateTimeFormatter. One reason is probably that a DateTimeFormatter wasn't necessarily created from a pattern; for example DateTimeFormat.forStyle() does not use patterns at all. However if you always use patterns, then you could wrap the

Pattern String from a joda-time DateTimeFormatter?

寵の児 提交于 2019-12-31 21:43:11
问题 Is it possible to get the pattern string from a joda-time DateTimeFormatter? DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMdd"); String originalPattern = formatter. ??? 回答1: Joda Time does not provide a way to get the original pattern from a DateTimeFormatter. One reason is probably that a DateTimeFormatter wasn't necessarily created from a pattern; for example DateTimeFormat.forStyle() does not use patterns at all. However if you always use patterns, then you could wrap the

Overriding BeanPropertyRowMapper to Support JodaTime DateTime

ε祈祈猫儿з 提交于 2019-12-31 21:35:13
问题 My Domain object has couple of Joda-Time DateTime fields. When I'm reading database values using SimpleJdbcTemplate: Patient patient = jdbc.queryForObject(sql, new BeanPropertyRowMapper(Patient.class), patientId); It just fails and surprisingly, no errors were logged. I guess it's because of the timestamp parsing to DateTime is not working with Jdbc. If it's possible to inherit and override BeanPropertyRowMapper and instruct to convert all java.sql.Timestamp and java.sql.Date to DateTime , it