joda

check if date is within time range using joda or standart java api

I have first time as string '12:00:00' and another '19:00:00' next how to check time portion of the day is within these time values? ...

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

How to get short month names in Joda Time?

Hello Does anyone know if there's a method in Joda Time or Java itself which takes either an int or a String as an argument, e.g. 4 or "4" and gives the name of the month back in short format, i.e. JAN for January? I suppose long month names can be truncated and converted to upper case. Thanks Mr Morgan. ...

Elapsed Time with Joda

Hello, I have a DataTime field that I need to see if it's 10 years or more in the past (Think of expiring certifications). I'm new to Joda, how is that done? Thanks for your help. ...

Using Joda Date & Time API to parse multiple formats

I'm parsing third party log files containing date/time using Joda. The date/time is in one of two different formats, depending on the age of the log files I'm parsing. Currently I have code like this: try { return DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").parseDateTime(datePart); } catch (IllegalArgumentException e) { re...

How to convert Joda LocalDate to String in Java?

I got the answer: It's very simple. DateTimeFormatter fmt = DateTimeFormat.forPattern("MM/dd/yyyy"); String formattedDate = jodeLocalDateObj.toString( fmt ); ...

Bug in jodatime Period?

How come this test I wrote fails in jodatime 1.6.2? Is it a bug? @Test public void testIfJodaTimePeriodsHandlesPeriodTypesOtherThanMinutesAndHours() { long twentyDaysInMillis = TimeUnit.MILLISECONDS.convert(20, TimeUnit.DAYS); Period twoWeeks = new Period(twentyDaysInMillis, PeriodType.weeks()); Assert.assertEquals(2, twoWeeks.ge...

Joda Time: Convert UTC to local

I want to convert a Joda Time UTC DateTime object to local time. Here's a laborious way to do it which seems to work. But there must be a better way. Here's the code (in Scala) without surrounding declarations: val dtUTC = new DateTime("2010-10-28T04:00") println("dtUTC = " + dtUTC) val dtLocal = timestampLocal(dtUTC) ...

Joda Time subtracting 24 hours from an instance of MutableDateTime, I would like to know why

I do not understand why MutableDateTime.setDate() is setting the time to "yesterday" (see the log timestamp hours - it is 20:28). Is this timezone related? Do I need to set something on the formatter? I would expect that after calling setDate with "10/27/2010", the date would be the same as the parsed date 00:00 EDT 10/27/10, instead ...