jodatime

(De)Serialize DateTime (Joda) with Jackson

大兔子大兔子 提交于 2019-12-24 10:53:41
问题 I am building a REST webservice. Some classes have an attribute of type DateTime (JodaTime). When sending this object to my client (Javascript), my object private DateTime date; is transformed to { date: { chronology: {}, millis: 1487289600000 } } The problem is that I have an error when sending this object back to the server because I cannot instantiate chronology I would like to have something like { date: 1487289600000} - Any other format could work. Environment jackson-annotations 2.8.8

How to use joda time to format a fixed number of millisecons to hh:mm:ss?

旧时模样 提交于 2019-12-24 04:07:08
问题 I have input, 34600 milliseconds I would like to output this in the format 00:00:34 (HH:MM:SS). What classes should I look at JDK / Joda-time for this? I need this to be efficient, preferably thread safe to avoid object creations on each parsing. Thank you. -- EDIT -- Using this code produces time zone sensitive results, how can I make sure the formating is "natural", i.e. uses absolute values. import java.util.Locale; import org.joda.time.format.DateTimeFormat; import org.joda.time.format

Grails unable to unmarshall date/time from JSON back into joda DateTime

◇◆丶佛笑我妖孽 提交于 2019-12-23 22:57:57
问题 I'm having trouble using the JodaTime plugin for Grails. The plugin seems to be correctly converting to JSON for the output, but it does not seem to be able to accept the outputted date format again as input when the same JSON object is sent back in. These are the errors I get: Field error in object 'server.Session' on field 'lastUpdated': rejected value [2011-12-19T14:15:03-06:00]; codes [typeMismatch.server.Session.lastUpdated,typeMismatch.lastUpdated,typeMismatch.org.joda.time.DateTime

JodaTime rounding down to nearest quarter of hour

左心房为你撑大大i 提交于 2019-12-23 21:08:00
问题 If the time is 10:36 I would like to round the time down to 10:30. If the time is 1050 I would like to round the time down to 10:45. etc... I am not sure how to do this. Any ideas? 回答1: How about this? public static LocalTime roundToQuarterHour(LocalTime time) { int oldMinute = time.getMinuteOfHour(); int newMinute = 15 * (int) Math.round(oldMinute / 15.0); return time.plusMinutes(newMinute - oldMinute); } (It may seem slightly overcomplicated since there's a withMinuteOfHour method, but keep

NoSuchMethodError - Calling Class/Method from Class in Same Package

夙愿已清 提交于 2019-12-23 20:21:09
问题 We are integrating an internal framework into our weblogic application and we are running into deployment problems. Technologies Used Weblogic 10.3.6 application Spring 3.0 Maven 2 Eclipse J2EE The Problem On startup of the weblogic application, we receive the following NoSuchMethodError while initializing one of the beans. This error is occuring when calling classes in the org.joda.time (2.0) jar. Caused By: java.lang.NoSuchMethodError: org.joda.time.DateTimeZone.convertLocalToUTC(JZ)J at

Android Java - Joda Date is slow in Eclipse/Emulator -

若如初见. 提交于 2019-12-23 19:32:55
问题 I am trying to find a set of date functions. Looks like the Joda http://www.joda.org/joda-time/ Does everything I need, but when I call a simple DateTime dt = new DateTime(); it hangs the Eclipse or Emulator for about 15 seconds. I must be doing something wrong as I haven't found anyone else complaining about it being slow. Short of the Joda jar anyone had a datediff() code sample? 回答1: I can confirm this in version 1, 1.5 and 1.62 ... I got bored after that and instead used Date4J which

XmlAdapter to JAXB-bind Joda Time Interval?

﹥>﹥吖頭↗ 提交于 2019-12-23 18:39:43
问题 I've been stuck for a few hours with a problem in my JAXB bindings for a web service: In order to prepare for a bigger web service that has to return Joda Time class instances (Instant, Duration, Interval, etc.) I've started with a web service that has only one method returning an Interval: package jodaws; import javax.jws.WebService; import javax.xml.ws.Endpoint; import org.joda.time.Interval; @WebService(name = "JodaWS") public class JodaWebService { public Interval readInterval() { return

UTC to local time in millis using JodaTime

[亡魂溺海] 提交于 2019-12-23 17:33:09
问题 I am attempting to show transactions over a certain time period using Jodatime. Our server requires a start date and end date to be in UTC (which is probably obvious). Therefore any business logic around these is using DateTime object with the timezone set to DateTimeZone.UTC , e.g. mStartDate = DateTime.now(UTC).withTimeAtStartOfDay(); That works well except when it comes to display the time I don't know how to augment it for the local (system default) timezone. Ideally I would like to use

Work-around for a Joda Time bug in PeriodFormat?

二次信任 提交于 2019-12-23 17:06:44
问题 Here's my code which reveals a Joda Time bug: import org.joda.time.Period; import org.joda.time.format.PeriodFormat; import org.joda.time.format.PeriodFormatter; import java.util.Locale; public class ScratchSpace { public static void main(String[] args) { Locale.setDefault(Locale.GERMAN); final PeriodFormatter periodFormatter = PeriodFormat.wordBased(Locale.ENGLISH); final Period period = new Period(6, 5, 4, 3); final String s = period.toString(periodFormatter); // i'm expecting english to be

Android L, exception using joda.time Library

て烟熏妆下的殇ゞ 提交于 2019-12-23 16:48:16
问题 An app used to work in all devices including (nexus 5 and nexus 7). Running the same app on Android L preview, the app crash. I have been debugging and the exception was founded calling DateTime Constructor. public static String[] getAge(Context context, Date date) { DateTime time = new DateTime(date); DateTime nowTime = new DateTime(new Date()); } Log: java.lang.SecurityException: Incorrect signature at org.apache.harmony.security.utils.JarUtils.verifySignature(JarUtils.java:223) at java