tags:

views:

42

answers:

2

I am new to Joda-Time and was looking at getting the previous working/week day. My initial try was done on a Monday and I wanted to get the date for T -1 which will be Friday:

DateTimeZone zone = DateTimeZone.forID("Europe/London");
Chronology coptic = GJChronology.getInstance(zone);

DateTime dt = new DateTime(coptic);
DateTime minusOneDay = dt.minusDays(1);

System.out.println(minusOneDay );

But as I expected returns the date on Sunday. Does anyone know how to get the previous week day? Thanks in advance..

A: 

If the day is Monday or Sunday, then you need to subtract three or two days respectively. In all other cases subtract one day. This assumes a working week from Monday to Friday (which doesn't apply to all cultures).

kgiannakakis
I was hoping that you could add a locale or calendar/chronology and that Joda-Time could do it for your. I don't really want to be saying, if it is Friday subtract 3 days and if Friday is a public holiday subtract 4 days etc... I want to be lazy and let someone else do this :-)
Shawn
+1  A: 

This doesn't look to be handled by Joda time.

There is a sourceforge project that looks to handle it though.

objectlabkit

Fortyrunner