jodatime

Decimal DateTime formatter in Java or Joda

I'm writing a file that requires dates to be in decimal format: 2007-04-24T13:18:09 becomes 39196.554270833331000 Does anyone have a time formatter that will do this (Decimal time is what VB/Office, etc. use)? Basic code goes like follows: final DateTime date = new DateTime(2007, 04, 24, 13, 18, 9, 0, DateTimeZone.UTC); double ...

Approach to convert from org.joda.time.DateTime to java.util.Calendar

Anyone done this and can share? I see an option or two but want to know what others have accomplished. ...

Are there any cons to using jodatime?

I want to convince the architecture manager to include the joda time jar in our product. Do you know any disadvantages in using it? I think joda time needs to be constantly updated because of the files that it includes. And that is a disadvantage. Maybe I am wrong. Could you provide some clarity on the subject? Thanks ...

Find DST transition timestamp with java.util.TimeZone

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

Should I use Java date and time classes or go with a 3rd party library like Joda Time?

Hi, I'm creating a web based system which will be used in countries from all over the world. One type of data which must be stored is dates and times. What are the pros and cons of using the Java date and time classes compared to 3rd party libraries such as Joda time? I guess these third party libraries exist for a good reason, but I'v...

Best practice for ignoring year in date for date ranges

I need to model some information about seasons, and need to track them based on start / end date in a year-agnostic way. I.e. I need to allow users to define summer as being between, say, May 15th and September 10th, and do that for all years. I'll need to do a lot of checking of the type isThisDateInSeason). All the date manipulati...

Joda-time: First day in this year's ISO week 1

Hi, I would like to find out the date of the Monday in this year's ISO week 1 (For 2009 this would be Monday, Dec 29 2008). I'm sure that joda-time can handle this, but I just can't figure out the API (maybe it's just too late). Can anyone help? Thanks! ...

DateTime is within in interval in JodaTime

Is there a API method in JodaTime to see whether a DateTime is within [start, end], i.e. the boundary is included? Only thing I found was new Interval(start, end).contains(dateTime) but this seems to give false if dateTime equals end. ...

Adding a number of days to a JodaTime Instant

I'm trying to write a simple utility method for adding aninteger number of days to a Joda time instant. Here is my first stab. /** * Adds a number of days specified to the instant in time specified. * * @param instant - the date to be added to * @param numberOfDaysToAdd - the number of days to be added to the instant specified * @r...

Can I construct a jodatime.Duration object with milliseconds resolution?

The API doesn't seem promising. ...

How to use JodaTime with java.sql.Timestamp

I Have a prepared statement INSERT INTO mst(time) VALUES (?); where time is of type Timestamp in a PostgreSQL database. I am inserting a Joda DateTime object, or I should say I am trying to. I can find no way to convert the DateTime ovject into a java.sql.Timestamp. I have read the Joda docs and see no reference to this. Thanks. ...

Java Joda Time - Implement a Date range iterator

Hi all, I'm trying to implement without success a Date iterator with Joda time. I need something that allows me to iterate all the days form startDate to endDate Do you have any idea on how to do that? ...

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

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

format years bc/ac differently

I would like to display e.g. 31-12-1999 for years ac and 31-12-(-)2000 for years bc. I spent some time with the joda api's e.g. something like: new DateTimeFormatterBuilder().appendYear(4, 10).appendLiteral("-").appendMonthOfYear(2).appendLiteral("-").appendDayOfMonth(2).toFormatter(); but I cannot find any details about this specific...

Date and Time helper for PHP (like jodatime in java)

Hi, I am looking for library (open source) like Joda Time in Java world. is there any library like that ? Joda Time is very helpful to calculate date and time. I can add days, weeks, month, year and also can converting date and time easily. I wish there is library like joda time for PHP edit: I need some functions that available in...

How can I parse a date including timezone with Joda Time

This snippet of code always parses the date into the current timezone, and not into the timezone in the string being parsed. final DateTimeFormatter df = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss 'GMT'Z yyyy"); final DateTime dateTime = df.parseDateTime("Mon Aug 24 12:36:46 GMT+1000 2009"); System.out.println("dateTime = " + d...

Joda-Time: Period to string

I'm using the Joda-Time library with Java. I'm having some difficulty trying to turn a Period object to a string in the format of "x days, x hours, x minutes". These Period objects are first created by adding an amount of seconds to them (they are serialized to XML as seconds and then recreated from them). If I simply use the getHours()...

Is it possible to change the base millisecond refrence time 1970 to 2008 in java (like JSR-310)

I want to be able to change the base millisecond reference from 1970 to 2008 in java so that I can save space in the database and unique Ids. Preferably with Joda-Time. The upcoming jsr-310 in the supposed java 7 release implements it. In the The Discrete Timeline section of this link it states that the counting of milliseconds has ch...

Date vs Milliseconds | for scalablility, saving, searching and obtaining time in Java + MySQL(or other Db's)

Which is the most beneficial in Java and a DB for DateTime? (Using JodaTime as Date) (DateTime object (Java) + TIMESTAMP (DB) ) VS (Milliseconds long (Java) + BIGINT(DB) for the use of DateTime information in Java Web application backed by an underlying Database Areas of interest manipulating, processing and memory usage in Java s...

How can i tell if one joda-time DateTime object is within 4 hours of another?

What's the best way to tell if one joda time DateTime object is within 4 hours of another if I don't know which object is earlier than the other? The Joda Time Duration object seems to do this job well if I know that object A comes before object B, but since Duration is signed it doesn't seem to do what I want if I don't know the order....