Hi, so I was having a problem parsing a date, using the JodaTime chronology IslamicChronology so wrote a small example to demonstrate my problem.
Here's the code:
import org.joda.time.Chronology;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.chrono.IslamicChronology;
im...
Is there a way to force Joda time to parse dates only when they contain four digit years? For example:
2009-11-11 - should parse
09-11-11 - should not parse
Tried the following code:
DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
DateTimeFormatter formatter = builder.appendYear(4, 4).appendLiteral('-').appendMont...
How can I get the next friday with the Joda-Time API.
The LocalDate of today is today. It looks to me you have to decide whever you are before or after the friday of the current week. See this method:
private LocalDate calcNextFriday(LocalDate d) {
LocalDate friday = d.dayOfWeek().setCopy(5);
if (d.isBefore(friday)) {
return d.dayO...
I'm trying to port an app from Eclipse to IntelliJ. The app builds fine but it fails to run properly.
Here's a partial stack trace I receive:
ERROR/AndroidRuntime(957):
java.io.IOException: Resource not found: "org/joda/time/tz/data/ZoneInfoMap" ClassLoader: dalvik.system.PathClassLoader@43761190
at org.joda.time....
I read (dont't know where anymore, but see here)
when using Jodatime you have to keep files up to date.
What kind of files? Why is that?
...
I'm using the Joda time (1.6) libraries and it keeps returning DateTime objects with the wrong time zone, British Summer Time instead of GMT.
My Windows workstation (running JDK 1.6.0_16) thinks it's in GMT and if I get the default time zone from the JDK date/time classes it is correct (GMT). I get the same behaviour on our Linux server...
I'm using Joda Time, and I'm being passed DateTimeZones that are created using DateTimeZone.forOffsetHours(). I'd like to print these timezones using standard timezone acronyms such as "PST", "EST", etc.
However, whenever I print DateTimes that use these timezones, I get an "hh:mm" representation of the timezone instead of the name acr...
I've read rumors that Joda Time is slated to be included in Java 7, but am having trouble locating a definitive source for this information. Will Joda Time be included in a future JDK? Please cite your source.
...
Hi all
I want to work out the next payment date in my code. I have a start date and i have a payment frequency which can be DAY, WEEK, MONTH or YEAR. So if the start date was 10 FEB 2009 and had a payment frequency of MONTH and the current date is 13 NOV 2009 then the next payment date would be 10 DEC 2009
I have already written some ...
The javadoc for org.joda.time.format.ISODateTimeFormat.dateTime() is:
Returns a formatter that combines a full date and time, separated by a 'T' (yyyy-MM-dd'T'HH:mm:ss.SSSZZ). The time zone offset is 'Z' for zero, and of the form '±HH:mm' for non-zero.
It is not clear to me where the word 'zero' is pointing at/to. Zero where or wha...
How do you get the first day of week given a Locale using Joda Time?
Point: Most countries use the international standard Monday as first day of week (!). A bunch others use Sunday (notably USA). Others apparently Saturday. Some apparently Wednesday?!
Wikipedia "Seven-day week"#Week_number
...
I am sure that someone familiar with HQL (I am myself a newbie) can easily answer this question.
In my Grails application, I have the following domain class.
class Book {
org.joda.time.DateTime releaseDate //I use the PersistentDateTime for persisting via Hibernate (that use a DATETIME type for MySQL DB)
}
In my HQL query, I want t...
I'm new to joda-time and I didn't find anywhere examples to do some simple things.
I want to make an object where to save a time value read from a table in a database (a java.sql.Time - e.g. "18:30:00") I don't care about time zone, so I think that I need LocalDate. But the problem is that I couldn't create a LocalDate object based on t...
I'd love to be able to parse relative strings like now and yesterday and get JodaTime DateTimes. Is it possible? DateTimeFormat.forPattern and doesn't seem to support English relative times and I don't know of any other parsing options in JodaTime.
I should add that I'm using scala-time but can easily drop down to the actual JodaTime cl...
Hi,
According to their website, the class DUration implements the ISO 8601
http://en.wikipedia.org/wiki/ISO%5F8601#Durations
But let see an example. It is a duration of 14min & 51sec.
In ISO 8601 those code are equivalent :
PT14M51S
PT891S
System.out.println("bug "+new Duration("PT14M51S"));
System.out.println("NO bug "+new...
Using Groovy (or Java) how can I convert a org.joda.time.LocalDateTime to a java.util.Date?
import org.joda.time.*
Calendar cal = Calendar.instance
cal.set(Calendar.DATE, 1)
cal.set(Calendar.HOUR, 0)
cal.set(Calendar.MINUTE, 0)
cal.set(Calendar.SECOND, 0)
cal.set(Calendar.MILLISECOND, 0)
Date startOfTheMonth = cal....
Hello,
I would like to calculate a duration whereas 1 day will consist of 8 hours.
Is creating a new Chronology is the right approach ?
I did try to create a custom Chronology and override the assemble method with something like:
int millisPerDay = 1000 * 60 * 60 * 8;
fields.days = new PreciseDurationField(DurationFieldType.days(), m...
I've created a method that takes two dates (in milliseconds) and returns a sentence that indicates the duration between these two dates.
For the moment, I have this code:
public static String formatDuration(long start, long end) {
Interval interval = new Interval(start, end);
return getPeriodFormatter().print(interval.toPeriod(...
Currently I have a function which can take the start time and end time of one day, and calculate the difference between the two, giving me the hours worked in a day. What I would like to do is be able to get the hours worked for 7 days, and return a grand total, while remaining with the display format (HH:mm).
My function for a single d...
I'm trying to work with a timeseries of monthly data. That is, there is a value for each month, and no specific date (or time) associated with it.
I could have arbitrarily fixed the day, time at some constant (eg midnight on first of the month) then used a java.util.date or joda DateTime but decided to try and do this within the joda t...