jodatime

JodaTime DateFormatter to display milliseconds if nonzero

I want to display a list of dates that may or may not have milliseconds on them. If a certain entry has milliseconds, then it should be displayed like yyyy MM dd HH:mm:ss.SSS. If it doesn't have the millis, I need it displayed as yyyy MM dd HH:mm:ss. I suppose the general question is: Is there a way to describe an optional format stri...

Does a library exist with Joda Time / iBATIS integration classes?

It looks like I have to implement com.ibatis.sqlmap.client.extensions.TypeHandlerCallback for both DateTime and LocalDateTime Joda types. This isn't a big deal, but if it's implemented somewhere else I'd rather just use that. ...

JODA time in Java Appengine

Has anyone gotten JODA time classes to work on Google Appengine? I'm using 1.3.4 of the java sdk and I get the following error when trying: java.lang.NoClassDefFoundError: com/google/appengine/repackaged/org/joda/time/DateTimeZone I've imported it as well: import com.google.appengine.repackaged.org.joda.time.DateTime; ...

String to date (Invalid format)

I am using Joda Time library to convert my String dates to a real date, because this seemed like the easiest solution to do this. I am using the DateTime object to do this; new DateTime(strValue); But when inserting some formats it throws me the exception; java.lang.IllegalArgumentException: Invalid format: "Mon, 30 Sep 2002 01:56:0...

Joda time : DateTimeFormatter : beginning of a day

Hello, DateTimeFormatter fmt = DateTimeFormat.forStyle('SS').withLocale(locale) DateTime dt = fmt.parseDateTime("11/4/03 8:14 PM"); the above statement will parse the string correctly, and save as DateTime (Joda Time). Now how to represent the beginning of a day. The below fails with DateTime dt = fmt.parseDateTime("11/4/03 00:01...

GPS Time Representation library

I am looking for a Java library that handles conversion to/from GPS Time. GPS Time has an epoch of 6 January 1980, and does not have leap seconds, so it differs from the more standard time representations. Here is the relevant description from wikipedia: While most clocks are synchronized to Coordinated Universal Time (UTC), the ...

How to serialize Joda DateTime with Jackson JSON processer?

How do I get Jackson to serialize my Joda DateTime object according to a simple pattern (like "dd-MM-yyyy"? I've tried: @JsonSerialize(using=DateTimeSerializer.class) private final DateTime date; I've tried: ObjectMapper mapper = new ObjectMapper() .getSerializationConfig() .setDateFormat(df); Thanks! ...

Any way to convert a JodaTime Period to a decimal number of hours?

I have a JodaTime Period that I've created from two DateTime instants. Is there a good way to convert that Period into a decimal number of hours? For instance, I have a Period that goes from 1pm to 1:30pm on Jan 1, 2010. How can I get that Period as 1.5 hours. In the past I've manually converted using seconds and BigDecimals such as ...

Difference in Days between two Java dates?

Hi All, I want to get the difference between two Java Date objects. I've used Joda-Time library. But the problem is that I'm getting the Days greater difference than that of actual day difference. Here's my code snippet: DateFormat formatter = new SimpleDateFormat("mm/dd/yyyy"); Date someDate=new Date(); Date today = Calendar.getIn...

implementing and interfaces which already implemented by super class?

In Joda I saw that Instant class extends AbstractInstant and implements Readable which is already implemented in AbstractInstant. What is the reason behind this?. ...

Android force close with JodaTime

Has anybody used jodatime with android? I'm getting a force close with no trace. package test.journal.help; import java.util.Date; import org.joda.time.DateTime; import org.joda.time.Days; import android.app.Activity; import android.os.Bundle; public class journaltester extends Activity { /** Called when the activity is first cr...

problem using Hibernate annotation with JodaTime

Hi,i am coming back because i still have problem using JodaTime. After the previous comments, i modified my pom and the @Type annotation is fixed. Here is my new pom : <properties> <org.springframework.version>3.0.3.RELEASE</org.springframework.version> <hibernate.version>3.6.0.Beta1</hibernate.version> </properties> <dependenci...

Recompile jodatime?

This is my first time using jodatime and i've got a stackoverflow error that i have no idea how to fix. I'm creating an android app that needs to be able to display the days between when a sqlite record was created and today. As far as i can tell everything is working correctly except jodatime. I got this error when building the project ...

Parsing xs:date with timezone into Joda LocalDate

When parsing dates and times from XML documents into JodaTime objects, I use a common set of conversion utilities, generally using the parsers and formatters supplied by org.joda.time.format.ISODateTimeFormat. This works fine in the majority of cases, but this time I'm seeing documents with the xs:date value of the format 2010-08-19Z. T...

What's the standard way to work with dates and times in Scala? Should I use Java types or there are native Scala alternatives?

What's the standard way to work with dates and times in Scala? Should I use Java types such as java.util.Date or there are native Scala alternatives? ...

How to substract a day/hour/minute from joda-time DateTime in Scala?

I am trying to use joda-time with its Scala wrapper. Saying val dt is a DateTime and contains a date (zero time), how do I get the date of the day befor it? dt - 1.days doesn't work and gives "type mismatch" ("found: org.scala_tools.time.Imports.DateTime, required: ?{val -:?}"). Scala-time examples like 2.hours + 45.minutes + 10.sec...

How can I find out if a string is parseable with jodatimes DateTime constructor?

I need to determine if an input string input can be parsed by jodatimes DateTime constructor Datetime(Object instant) but I'm not interested in creating the DateTime object at this time. Is there any way to check if the string is parseable beside calling the constructor and catch the possible exception? ...

Hibernate date conversion

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 ent...

How to sum 2 joda-time DateTime values (one containing a date and a zero time and another containing a time and a zero date)?

In a Scala 2.8 program of mine I use joda-time with its scala-time wrapper. I've got 2 DateTime values, one for a date (with zero time fields) and one for time (with zero date fields) (the reason of separation is a storage architecture). How do I get another DateTime value with both date and time parts set from a source pair? ...

StackOverflowError using joda-time new Period(long)

First, sorry this is so long. I probably don't need all the code, but wanted to be sure. Second, my actual question is, am I doing something wrong, or is this a bug in the joda-time library? I'm trying to use joda-time (1.6.1) to calculate, then format time durations. I'm currently using Period, which may be the wrong choice. Please l...