jodatime

Any relation between Quartz API and Joda Time API?

点点圈 提交于 2019-12-09 09:45:04
问题 Is it possible to create a date in JodaTime and then make Quartz schedule the job using the JodaTime object? Can we give a Period jodaPeriod to Quartz API in order to run a task for a particular period in a day? Are the two APIs related and/or compatible in any way? 回答1: The AxonFramework has a QuartzEventScheduler which looks like it does what you want. Here's the downlaod page and it's under the Apache 2.0 license. 回答2: Quartz provides a pretty comprehensive API that you could extend anyway

How do I create a new Joda DateTime truncated to the last hour? [duplicate]

此生再无相见时 提交于 2019-12-09 05:00:44
问题 This question already has answers here : JodaTime equivalent of DateUtils.truncate() (4 answers) Closed 4 years ago . I am pulling timestamps from a file that I want to create a new DateTime for, but I want to create the DateTime at the floor of the hour (or any Joda Period will do). How Can I do this? 回答1: Wohoo, found it. Simple like everything in Joda once I traced down the calls. DateTime dt = new DateTime().hourOfDay().roundFloorCopy(); 来源: https://stackoverflow.com/questions/1207957/how

How to convert Joda Localdate to Joda DateTime?

戏子无情 提交于 2019-12-09 04:27:44
问题 I'm trying to simply add TimeZone information back into a LocalDate before performing some more calculations. The LocalDate came from using the ObjectLab LocalDateCalculator to add days to an existing DateTime but the method needs to return a modified ReadableInstant to form an Interval which I can then inspect. The code I'm trying amounts to a conversion of Joda LocalDate to Joda DateTime: LocalDate contextLocalBusinessDate = calculator.getCurrentBusinessDate(); DateTime

How to store date-time in UTC into a database using EclipseLink and Joda-Time?

一曲冷凌霜 提交于 2019-12-09 03:23:43
问题 I have been fumbling with the following EclipseLink Joda-Time converter for a long time to store date-time in UTC into MySQL database with no success at all. import java.util.Date; import org.eclipse.persistence.mappings.DatabaseMapping; import org.eclipse.persistence.mappings.converters.Converter; import org.eclipse.persistence.sessions.Session; import org.joda.time.DateTime; public final class JodaDateTimeConverter implements Converter { private static final long serialVersionUID = 1L;

DateTimeFormatter.parseLocalDate throws UnsupportedOperationException

淺唱寂寞╮ 提交于 2019-12-08 19:38:08
问题 The API for parseLocalDate says it will throw UnsupportedOperationException "if parsing is not supported". What does it mean by 'if parsing is not supported'? I'm looking through the source and can not find anywhere that throws UnsupportedOperationException . Has anyone ever been in a scenario where this exception was thrown from calling parseLocalDate ? 回答1: DateTimeFormatter have two usages: print dates; parse dates; When you create DateTimeFormatter instance, you pass to it DateTimePrinter

Converting joda LocalTime to sql Time

我只是一个虾纸丫 提交于 2019-12-08 19:35:56
问题 I want to convert a LocalTime object to a java.sql.Time object. java.sql.Time time = new java.sql.Time(new LocalTime(1,0,0,0).getMillisOfDay()); System.out.println(time); //20:00:00 The above code, instead of creating a Time object with a value equal to 01:00:00, creates an object with a time of 20:00:00. The local time is eastern time. What steps should I take? 回答1: Time(..) accepts a timestamp starting from 1970. So you should pass that: new Time(new LocalTime(...).toDateTimeToday()

Hibernate date conversion

六眼飞鱼酱① 提交于 2019-12-08 19:32:05
问题 I have a wierd hibernate related issue while setting a date field in an entity. The date is interpreted as UTC in the java program (i did a System.out to make sure the date assigned is in 'UTC'. However, when hibernate actually persists to the database, the date is converted to local time and stored) ex. the value has been set in the entity setter as "2009-09-09 00:08:08" - GMT the actual value persisted to the database is "2009-09-08 08:08:08" - eastern time US. I am unable to find out where

ProGuard didnt compile with Joda Time used in Windows

你。 提交于 2019-12-08 19:23:04
问题 Actually this is an answer and not a question anymore: I did spent many hours on Windows using JodaTime to be included in my Android project using ProGuard Proguard Configuration: -libraryjars C:\Users\Reto\Documents\GitHub\advanceIT\LoveClockPAY\libs\joda-time-2.1.jar I had the following errors: ProGuard didnt find my JAR and said: Can't read [C:\Users\Reto\Documents\GitHub\advanceIT\LoveClockPAY\libs\joda-time-2.1.jar] (No such file or directory) Solution -libraryjars libs/joda-time-2.1.jar

How to find nearest week day for an arbitrary date?

删除回忆录丶 提交于 2019-12-08 19:01:35
问题 Is there an elegant way to find the nearest day of the week for a given date using JodaTime? I initially thought setCopy() would be it, but this sets the day to the particular day in the same week . Thus, if ld is 2011-11-27 and day is "Monday" the following function returns 2011-11-21 , and not 2011-11-28 as I want. // Note that "day" can be _any_ day of the week, not just weekdays. LocalDate getNearestDayOfWeek(LocalDate ld, String day) { return ld.dayOfWeek().setCopy(day); } Desired output

Why does Joda time change the PM in my input string to AM?

半城伤御伤魂 提交于 2019-12-08 16:29:42
问题 My input string is a PM time: log(start); // Sunday, January 09, 2011 6:30:00 PM I'm using Joda Time's pattern syntax as follows to parse the DateTime: DateTimeFormatter parser1 = DateTimeFormat.forPattern("EEEE, MMMM dd, yyyy H:mm:ss aa"); DateTime startTime = parser1.parseDateTime(start); So, why is my output string AM? log(parser1.print(startTime)); // Sunday, January 09, 2011 6:30:00 AM 回答1: Your parse string contains "H" which is telling your parser to interpret the value as a 24-hour