Date range by week number Golang - date

With this simple function, I can get the week number. Now, with the number of the week, how can I get the date range, started on Sunday?
import (
"fmt"
"time"
)
func main() {
Week(time.Now().UTC())
}
func Week(now time.Time) string {
_, thisWeek := now.ISOWeek()
return "S" + strconv.Itoa(thisWeek)
}

Foreword: Time.ISOWeek() returns you the week number that starts on Monday, so I will answer your question that also handles weeks starting on Monday. Alter it to your needs if you want it to work with weeks starting on Sunday.
I released this utility in github.com/icza/gox, see timex.WeekStart().
The standard library does not provide a function that would return you the date range of a given week (year+week number). So we have to construct one ourselves.
And it's not that hard. We can start off from the middle of the year, align to the first day of the week (Monday), get the week of this time value, and corrigate: add as many days as the week difference multiplied by 7.
This is how it could look like:
func WeekStart(year, week int) time.Time {
// Start from the middle of the year:
t := time.Date(year, 7, 1, 0, 0, 0, 0, time.UTC)
// Roll back to Monday:
if wd := t.Weekday(); wd == time.Sunday {
t = t.AddDate(0, 0, -6)
} else {
t = t.AddDate(0, 0, -int(wd)+1)
}
// Difference in weeks:
_, w := t.ISOWeek()
t = t.AddDate(0, 0, (week-w)*7)
return t
}
Testing it:
fmt.Println(WeekStart(2018, 1))
fmt.Println(WeekStart(2018, 2))
fmt.Println(WeekStart(2019, 1))
fmt.Println(WeekStart(2019, 2))
Output (try it on the Go Playground):
2018-01-01 00:00:00 +0000 UTC
2018-01-08 00:00:00 +0000 UTC
2018-12-31 00:00:00 +0000 UTC
2019-01-07 00:00:00 +0000 UTC
One nice property of this WeekStart() implementation is that it handles out-of-range weeks nicely. That is, if you pass 0 for the week, it will be interpreted as the last week of the previous year. If you pass -1 for the week, it will designate the second to last week of the previous year. Similarly, if you pass max week of the year plus 1, it will be interpreted as the first week of the next year etc.
The above WeekStart() function only returns the given week's first day (Monday), because the last day of the week is always its first day + 6 days.
If we also need the last day:
func WeekRange(year, week int) (start, end time.Time) {
start = WeekStart(year, week)
end = start.AddDate(0, 0, 6)
return
}
Testing it:
fmt.Println(WeekRange(2018, 1))
fmt.Println(WeekRange(2018, 2))
fmt.Println(WeekRange(2019, 1))
fmt.Println(WeekRange(2019, 2))
Output (try it on the Go Playground):
2018-01-01 00:00:00 +0000 UTC 2018-01-07 00:00:00 +0000 UTC
2018-01-08 00:00:00 +0000 UTC 2018-01-14 00:00:00 +0000 UTC
2018-12-31 00:00:00 +0000 UTC 2019-01-06 00:00:00 +0000 UTC
2019-01-07 00:00:00 +0000 UTC 2019-01-13 00:00:00 +0000 UTC

The following does the work of finding the first day of week for me, although not from week number but from time. If you add an extra parameter - for the hard-coded time.Monday - that can be any day of week, e.g. Sunday.
func weekStartDate(date time.Time) time.Time {
offset := (int(time.Monday) - int(date.Weekday()) - 7) % 7
result := date.Add(time.Duration(offset*24) * time.Hour)
return result
}
Test:
func TestWeekStartDate(t *testing.T) {
date := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
for i := 0; i < 2000; i++ {
weekStart := weekStartDate(date)
log.Printf("%s %s", date.Format("2006-01-02 Mon"), weekStart.Format("2006-01-02 Mon"))
assert.NotNil(t, weekStart)
assert.Equal(t, time.Monday, weekStart.Weekday())
date = date.Add(24 * time.Hour)
}
}
Output:
...
2021/01/17 08:50:03 2020-12-15 Tue 2020-12-14 Mon
2021/01/17 08:50:03 2020-12-16 Wed 2020-12-14 Mon
2021/01/17 08:50:03 2020-12-17 Thu 2020-12-14 Mon
2021/01/17 08:50:03 2020-12-18 Fri 2020-12-14 Mon
2021/01/17 08:50:03 2020-12-19 Sat 2020-12-14 Mon
2021/01/17 08:50:03 2020-12-20 Sun 2020-12-14 Mon
2021/01/17 08:50:03 2020-12-21 Mon 2020-12-21 Mon
2021/01/17 08:50:03 2020-12-22 Tue 2020-12-21 Mon
2021/01/17 08:50:03 2020-12-23 Wed 2020-12-21 Mon
2021/01/17 08:50:03 2020-12-24 Thu 2020-12-21 Mon
2021/01/17 08:50:03 2020-12-25 Fri 2020-12-21 Mon
2021/01/17 08:50:03 2020-12-26 Sat 2020-12-21 Mon
2021/01/17 08:50:03 2020-12-27 Sun 2020-12-21 Mon
2021/01/17 08:50:03 2020-12-28 Mon 2020-12-28 Mon
2021/01/17 08:50:03 2020-12-29 Tue 2020-12-28 Mon
2021/01/17 08:50:03 2020-12-30 Wed 2020-12-28 Mon
2021/01/17 08:50:03 2020-12-31 Thu 2020-12-28 Mon
2021/01/17 08:50:03 2021-01-01 Fri 2020-12-28 Mon
2021/01/17 08:50:03 2021-01-02 Sat 2020-12-28 Mon
2021/01/17 08:50:03 2021-01-03 Sun 2020-12-28 Mon
2021/01/17 08:50:03 2021-01-04 Mon 2021-01-04 Mon
2021/01/17 08:50:03 2021-01-05 Tue 2021-01-04 Mon
2021/01/17 08:50:03 2021-01-06 Wed 2021-01-04 Mon
2021/01/17 08:50:03 2021-01-07 Thu 2021-01-04 Mon
2021/01/17 08:50:03 2021-01-08 Fri 2021-01-04 Mon
2021/01/17 08:50:03 2021-01-09 Sat 2021-01-04 Mon
2021/01/17 08:50:03 2021-01-10 Sun 2021-01-04 Mon
2021/01/17 08:50:03 2021-01-11 Mon 2021-01-11 Mon
2021/01/17 08:50:03 2021-01-12 Tue 2021-01-11 Mon
2021/01/17 08:50:03 2021-01-13 Wed 2021-01-11 Mon
2021/01/17 08:50:03 2021-01-14 Thu 2021-01-11 Mon
2021/01/17 08:50:03 2021-01-15 Fri 2021-01-11 Mon
2021/01/17 08:50:03 2021-01-16 Sat 2021-01-11 Mon
2021/01/17 08:50:03 2021-01-17 Sun 2021-01-11 Mon
2021/01/17 08:50:03 2021-01-18 Mon 2021-01-18 Mon
2021/01/17 08:50:03 2021-01-19 Tue 2021-01-18 Mon
2021/01/17 08:50:03 2021-01-20 Wed 2021-01-18 Mon
2021/01/17 08:50:03 2021-01-21 Thu 2021-01-18 Mon
2021/01/17 08:50:03 2021-01-22 Fri 2021-01-18 Mon
2021/01/17 08:50:03 2021-01-23 Sat 2021-01-18 Mon
2021/01/17 08:50:03 2021-01-24 Sun 2021-01-18 Mon
2021/01/17 08:50:03 2021-01-25 Mon 2021-01-25 Mon
2021/01/17 08:50:03 2021-01-26 Tue 2021-01-25 Mon
2021/01/17 08:50:03 2021-01-27 Wed 2021-01-25 Mon
2021/01/17 08:50:03 2021-01-28 Thu 2021-01-25 Mon
2021/01/17 08:50:03 2021-01-29 Fri 2021-01-25 Mon
2021/01/17 08:50:03 2021-01-30 Sat 2021-01-25 Mon
2021/01/17 08:50:03 2021-01-31 Sun 2021-01-25 Mon
2021/01/17 08:50:03 2021-02-01 Mon 2021-02-01 Mon
2021/01/17 08:50:03 2021-02-02 Tue 2021-02-01 Mon
2021/01/17 08:50:03 2021-02-03 Wed 2021-02-01 Mon
2021/01/17 08:50:03 2021-02-04 Thu 2021-02-01 Mon
2021/01/17 08:50:03 2021-02-05 Fri 2021-02-01 Mon
...

Thanks to #prajwal Singh, I've found more generic to find out the start and last day of the week w.r.t month, week, and year
func DateRange(week, month, year int) (startDate, endDate time.Time) {
timeBenchmark := time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.UTC)
weekStartBenchmark := timeBenchmark.AddDate(0, 0, -(int(timeBenchmark.Weekday())+6)%7)
startDate = weekStartBenchmark.AddDate(0, 0, (week-1)*7)
endDate = startDate.AddDate(0, 0, 6)
return startDate, endDate
}

Thanks to #icza for the solution, found a way to simplify it even further in terms of logic:
func DateRange(week, year int) (startDate, endDate time.Time) {
timeBenchmark := time.Date(year, 7, 1, 0, 0, 0, 0, time.UTC)
weekStartBenchmark := timeBenchmark.AddDate(0, 0, -(int(timeBenchmark.Weekday())+6)%7)
_, weekBenchmark := weekStartBenchmark.ISOWeek()
startDate = weekStartBenchmark.AddDate(0, 0, (week-weekBenchmark)*7)
endDate = startDate.AddDate(0, 0, 6)
return startDate, endDate
}
Works fine as well.

Related

Swift Get First Date of Month not working

I am trying to get the month and year of a date so I can generate month sections in a table view. My plan is to create a dictionary of dates that contains the unique months per year (January 2022:[], January 2023:[]) as the keys, and then each item containing an array of all the dates
When I run the below code, it gets the first date of the month for some dates, but it seems to get the last date of the month for others and I cannot for the life of me figure out why.
Code
let dateList = ["2023-01-26 02:30:53 +0000",
"2022-12-28 09:42:27 +0000",
"2022-11-09 05:48:42 +0000",
"2022-09-30 09:08:03 +0000",
"2022-08-31 10:22:31 +0000",
"2022-07-29 04:15:02 +0000",
"2022-06-20 12:57:35 +0000",
"2022-05-12 15:36:37 +0000",
"2022-04-18 03:14:29 +0000",
"2022-03-10 02:40:42 +0000",
"2022-02-07 18:03:15 +0000",
"2022-01-18 15:18:24 +0000"]
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ssZ"
for dates in dateList {
let currentDate = dateFormatter.date(from:dates)!
let components = Calendar.current.dateComponents(
[.month, .year],
from: currentDate
)
let monthName = Calendar.current.monthSymbols[components.month!-1]
let year = components.year!
var dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd MM yyyy"
let month = Calendar.current.date(from: components)
print("\(currentDate) |||||", "\(month!) |||||", "\(components.month!-1) |||||", "\(year) \(monthName)")
}
Output
Original Date First Date of Month monthName
2023-01-26 02:30:53 +0000 ||||| 2023-01-01 00:00:00 +0000 ||||| 0 ||||| 2023 January
2022-12-28 09:42:27 +0000 ||||| 2022-12-01 00:00:00 +0000 ||||| 11 ||||| 2022 December
2022-11-09 05:48:42 +0000 ||||| 2022-11-01 00:00:00 +0000 ||||| 10 ||||| 2022 November
2022-09-30 09:08:03 +0000 ||||| 2022-08-31 23:00:00 +0000 ||||| 8 ||||| 2022 September
2022-08-31 10:22:31 +0000 ||||| 2022-07-31 23:00:00 +0000 ||||| 7 ||||| 2022 August
2022-07-29 04:15:02 +0000 ||||| 2022-06-30 23:00:00 +0000 ||||| 6 ||||| 2022 July
2022-06-20 12:57:35 +0000 ||||| 2022-05-31 23:00:00 +0000 ||||| 5 ||||| 2022 June
2022-05-12 15:36:37 +0000 ||||| 2022-04-30 23:00:00 +0000 ||||| 4 ||||| 2022 May
2022-04-18 03:14:29 +0000 ||||| 2022-03-31 23:00:00 +0000 ||||| 3 ||||| 2022 April
2022-03-10 02:40:42 +0000 ||||| 2022-03-01 00:00:00 +0000 ||||| 2 ||||| 2022 March
2022-02-07 18:03:15 +0000 ||||| 2022-02-01 00:00:00 +0000 ||||| 1 ||||| 2022 February
2022-01-18 15:18:24 +0000 ||||| 2022-01-01 00:00:00 +0000 ||||| 0 ||||| 2022 January
Expected Output
2023-01-26 02:30:53 +0000 ||||| 2023-01-01 00:00:00 +0000 ||||| 0 ||||| 2023 January
2022-12-28 09:42:27 +0000 ||||| 2022-12-01 00:00:00 +0000 ||||| 11 ||||| 2022 December
2022-11-09 05:48:42 +0000 ||||| 2022-11-01 00:00:00 +0000 ||||| 10 ||||| 2022 November
2022-09-30 09:08:03 +0000 ||||| 2022-09-01 00:00:00 +0000 ||||| 8 ||||| 2022 September
2022-08-31 10:22:31 +0000 ||||| 2022-08-01 00:00:00 +0000 ||||| 7 ||||| 2022 August
2022-07-29 04:15:02 +0000 ||||| 2022-07-01 00:00:00 +0000 ||||| 6 ||||| 2022 July
2022-06-20 12:57:35 +0000 ||||| 2022-06-01 00:00:00 +0000 ||||| 5 ||||| 2022 June
2022-05-12 15:36:37 +0000 ||||| 2022-05-01 00:00:00 +0000 ||||| 4 ||||| 2022 May
2022-04-18 03:14:29 +0000 ||||| 2022-04-01 00:00:00 +0000 ||||| 3 ||||| 2022 April
2022-03-10 02:40:42 +0000 ||||| 2022-03-01 00:00:00 +0000 ||||| 2 ||||| 2022 March
2022-02-07 18:03:15 +0000 ||||| 2022-02-01 00:00:00 +0000 ||||| 1 ||||| 2022 February
2022-01-18 15:18:24 +0000 ||||| 2022-01-01 00:00:00 +0000 ||||| 0 ||||| 2022 January
As you can see, September - April seem to have the wrong date created by the let month = Calendar.current.date(from: components).
Any ideas?
Your code is perfectly fine.
The odd behaviour occurs because print displays Date instances always in UTC.
Either create a string with the DateFormatter which does consider the current locale (recommended) or to fix the output of this code just replace the print line with
print("\(currentDate) |||||", "\(month!.description(with: .current)) |||||", "\(components.month!-1) |||||", "\(year) \(monthName)")
.description(with: .current) displays the Date in the current locale.
It's the localisation that's wrong. The date itself is correct, but the print outputs the date using your current timezone. Make sure to use the same date formatter in your print to get the same print result:
let dateFormatter = DateFormatter()
let dateList = ["2023-01-26 02:30:53 +0000",
"2022-12-28 09:42:27 +0000",
"2022-11-09 05:48:42 +0000",
"2022-09-30 09:08:03 +0000",
"2022-08-31 10:22:31 +0000",
"2022-07-29 04:15:02 +0000",
"2022-06-20 12:57:35 +0000",
"2022-05-12 15:36:37 +0000",
"2022-04-18 03:14:29 +0000",
"2022-03-10 02:40:42 +0000",
"2022-02-07 18:03:15 +0000",
"2022-01-18 15:18:24 +0000"]
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ssZ"
for dateString in dateList {
let currentDate = dateFormatter.date(from: dateString)!
let components = Calendar.current.dateComponents([.month, .year], from: currentDate)
let monthName = Calendar.current.monthSymbols[components.month!-1]
let year = components.year!
let monthDate = Calendar.current.date(from: components)
print("\(dateFormatter.string(from: currentDate)) |||||", "\(dateFormatter.string(from: monthDate!)) |||||", "\(components.month!-1) |||||", "\(year) \(monthName)")
}
I think I figured out why I was getting the odd behaviour.
Using Calendar.current.date(from: components) to create a date by only using the month and year creates a date that is the first hour of the month. I think what happens is that daylight savings time is then applied to that new date object, subtracting one hour for the dates that fall with the daylight savings period (March - October).
That explains why only April - September dates were only affected.
Changing the month constant to dateFormatter.date(from: "\(year)-\(components.month!)-01 00:00:00 +0000") gets the expected result that I am after, as you can see by the updated code below.
Code
var dateFormatter = DateFormatter()
let dateList = ["2023-01-26 02:30:53 +0000",
"2022-12-28 09:42:27 +0000",
"2022-11-09 05:48:42 +0000",
"2022-09-30 09:08:03 +0000",
"2022-08-31 10:22:31 +0000",
"2022-07-29 04:15:02 +0000",
"2022-06-20 12:57:35 +0000",
"2022-05-12 15:36:37 +0000",
"2022-04-18 03:14:29 +0000",
"2022-03-10 02:40:42 +0000",
"2022-02-07 18:03:15 +0000",
"2022-01-18 15:18:24 +0000",
"2022-09-30 09:08:03 +0000",
"2022-08-31 10:22:31 +0000",
"2022-07-29 04:15:02 +0000",
"2022-06-20 12:57:35 +0000",
"2022-05-12 15:36:37 +0000",
"2022-04-18 03:14:29 +0000",
"2023-01-26 02:30:53 +0000"]
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ssZ"
for dates in dateList {
var calendar = Calendar.current
let currentDate = dateFormatter.date(from:dates)!
var components = calendar.dateComponents(
[.day, .month, .year],
from: currentDate
)
let monthName = calendar.monthSymbols[components.month!-1]
let year = components.year!
let month = dateFormatter.date(from: "\(year)-\(components.month!)-01 00:00:00 +0000")
print("\(currentDate) |||||", "\(month!) |||||", "\(year) \(monthName)")
}
Output
2023-01-26 02:30:53 +0000 ||||| 2023-01-01 00:00:00 +0000 ||||| 2023-1-1 ||||| 2023 January
2022-12-28 09:42:27 +0000 ||||| 2022-12-01 00:00:00 +0000 ||||| 2022-12-1 ||||| 2022 December
2022-11-09 05:48:42 +0000 ||||| 2022-11-01 00:00:00 +0000 ||||| 2022-11-1 ||||| 2022 November
2022-09-30 09:08:03 +0000 ||||| 2022-09-01 00:00:00 +0000 ||||| 2022-9-1 ||||| 2022 September
2022-08-31 10:22:31 +0000 ||||| 2022-08-01 00:00:00 +0000 ||||| 2022-8-1 ||||| 2022 August
2022-07-29 04:15:02 +0000 ||||| 2022-07-01 00:00:00 +0000 ||||| 2022-7-1 ||||| 2022 July
2022-06-20 12:57:35 +0000 ||||| 2022-06-01 00:00:00 +0000 ||||| 2022-6-1 ||||| 2022 June
2022-05-12 15:36:37 +0000 ||||| 2022-05-01 00:00:00 +0000 ||||| 2022-5-1 ||||| 2022 May
2022-04-18 03:14:29 +0000 ||||| 2022-04-01 00:00:00 +0000 ||||| 2022-4-1 ||||| 2022 April
2022-03-10 02:40:42 +0000 ||||| 2022-03-01 00:00:00 +0000 ||||| 2022-3-1 ||||| 2022 March
2022-02-07 18:03:15 +0000 ||||| 2022-02-01 00:00:00 +0000 ||||| 2022-2-1 ||||| 2022 February
2022-01-18 15:18:24 +0000 ||||| 2022-01-01 00:00:00 +0000 ||||| 2022-1-1 ||||| 2022 January
2022-09-30 09:08:03 +0000 ||||| 2022-09-01 00:00:00 +0000 ||||| 2022-9-1 ||||| 2022 September
2022-08-31 10:22:31 +0000 ||||| 2022-08-01 00:00:00 +0000 ||||| 2022-8-1 ||||| 2022 August
2022-07-29 04:15:02 +0000 ||||| 2022-07-01 00:00:00 +0000 ||||| 2022-7-1 ||||| 2022 July
2022-06-20 12:57:35 +0000 ||||| 2022-06-01 00:00:00 +0000 ||||| 2022-6-1 ||||| 2022 June
2022-05-12 15:36:37 +0000 ||||| 2022-05-01 00:00:00 +0000 ||||| 2022-5-1 ||||| 2022 May
2022-04-18 03:14:29 +0000 ||||| 2022-04-01 00:00:00 +0000 ||||| 2022-4-1 ||||| 2022 April
2023-01-26 02:30:53 +0000 ||||| 2023-01-01 00:00:00 +0000 ||||| 2023-1-1 ||||| 2023 January
Thank you everyone for responding, I hope this helps someone else.

Single planning calendar with fullday off

I have a problem with Single planning calendar.
I set fullday to false and set a startHour (8h) and endHour (17h).
But when i want to resize an appointment the startDate is not correct.
handleAppointmentResize: function (oEvent) {
var oAppointment = oEvent.getParameter("appointment"),
oStartDate = oEvent.getParameter("startDate"),
oEndDate = oEvent.getParameter("endDate"),
sAppointmentTitle = oAppointment.getTitle();
console.log(oStartDate);
console.log(oEndDate);
For exemple :
I have an appointment :
Wed Apr 06 2022 09:00:00 to Wed Apr 06 2022 13:00:00
I reduce them to 09:00 - 10:00
The result is
Mon Apr 04 2022 19:30:00 GMT+0200 (heure d’été d’Europe centrale)
Wed Apr 06 2022 09:00:00 GMT+0200 (heure d’été d’Europe centrale)
If i switch fullday to true, the result is ok !
Thanks for help
Resolve with upgrade of Sapui5 version

Returns the value in the next empty rows

Input
Here is an example of my input.
Number
Date
Motore
1
Fri Jan 01 00:00:00 CET 2021
Motore 1
2
Motore 2
3
Motore 3
4
Motore 4
5
Fri Feb 01 00:00:00 CET 2021
Motore 1
6
Motore 2
7
Motore 3
8
Motore 4
Expected Output
Number
Date
Motore
1
Fri Jan 01 00:00:00 CET 2021
Motore 1
2
Fri Jan 01 00:00:00 CET 2021
Motore 2
3
Fri Jan 01 00:00:00 CET 2021
Motore 3
4
Fri Jan 01 00:00:00 CET 2021
Motore 4
5
Fri Feb 01 00:00:00 CET 2021
Motore 1
6
Fri Feb 01 00:00:00 CET 2021
Motore 2
7
Fri Feb 01 00:00:00 CET 2021
Motore 3
8
Fri Feb 01 00:00:00 CET 2021
Motore 4
I tried to use the TmemorizeRows component but without any result, the second line is valorized but the others are not. Could you kindly help me.
You can solve this with a simple tMap with 2 inner variables (using the "var" array in the middle of the tMap)
Create two variables :
currentValue : you put in it the value of your input column date (in my example "row1.data").
updateValue : check whether currentValue is null or not : if null then you do not modify updateValue field . If not null then you update the field value. This way "updateValue" always contains not null data.
In output, just use "updateValue" variable.

Why is only one data displayed in LineChart?

I got all the Reportstuff working, get a PDF generated and redirected as servlet response.
The Report opens up and the data I pass is there (tested with textfields...data is there). When I try to display the data in a line chart, it just shows one data point. I have grouped the chart on the 'day' data, as i want to have a new chart for every day (which also works, as there are 31 charts for my 31 days in testdata.
Plus I have multiple lines to display, bound by the 'type' data. So I want four lines on every diagram: the data itself (type=1), the min-value (type=2), the average value(type=3) and the max-value (type=3). But it just won't work...Where is my mistake?
Here's the code:
JasperReport:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="jasper_report_template" pageWidth="595" pageHeight="842" whenNoDataType="NoPages" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50" uuid="c5395651-075a-4d6a-a971-d283cab77f63">
<parameter name="ReportTitle" class="java.lang.String"/>
<parameter name="Author" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="day" class="java.lang.Integer">
<fieldDescription><![CDATA[day]]></fieldDescription>
</field>
<field name="type" class="java.lang.Integer">
<fieldDescription><![CDATA[type]]></fieldDescription>
</field>
<field name="time" class="java.lang.String">
<fieldDescription><![CDATA[time]]></fieldDescription>
</field>
<field name="kwh" class="java.lang.Double">
<fieldDescription><![CDATA[kwh]]></fieldDescription>
</field>
<sortField name="day"/>
<sortField name="type"/>
<group name="DayGroup" minHeightToStartNewPage="60">
<groupExpression><![CDATA[$F{day}]]></groupExpression>
<groupHeader>
<band height="210" splitType="Stretch">
<lineChart>
<chart evaluationTime="Group" evaluationGroup="DayGroup">
<reportElement x="-20" y="10" width="560" height="200" uuid="9abe6b47-1c6f-4bd0-a684-abf9e91b4adc"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset resetType="Group" resetGroup="DayGroup" incrementType="Group" incrementGroup="DayGroup"/>
<categorySeries>
<seriesExpression><![CDATA[$F{type}]]></seriesExpression>
<categoryExpression><![CDATA[$F{time}]]></categoryExpression>
<valueExpression><![CDATA[$F{kwh}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</linePlot>
</lineChart>
</band>
</groupHeader>
</group>
</jasperReport>
Servlet:
JRBeanCollectionDataSource jrbcds = new JRBeanCollectionDataSource(BasicDataHandler.getInstance().getThatBeanList());
String path = getServletContext().getRealPath("/reports/");
JasperReport jasReport = JasperCompileManager.compileReport(path+ "/template_all_month_line_graph.jrxml");
JasperPrint jasPrint;
jasPrint = JasperFillManager.fillReport(jasReport, null, jrbcds);
ServletOutputStream sos = response.getOutputStream();
response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasPrint, sos);
BasicDataHandler:
package sc2pdf.datahandlers;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import sc2pdf.datasets.DailyDataSet;
import sc2pdf.javabeans.DataObject;
public class BasicDataHandler {
private static BasicDataHandler myself=null;
private Map<Integer, DailyDataSet> data = null;
private Map<Integer, DailyDataSet> min_data = null;
private Map<Integer, DailyDataSet> avg_data = null;
private Map<Integer, DailyDataSet> max_data = null;
public BasicDataHandler() {
data = new HashMap<Integer, DailyDataSet>(); //holds all the real data values; key: DAY_OF_MONTH; value DailyDataSet for every day of month
min_data = new HashMap<Integer, DailyDataSet>(); //holds all the min data values; key: DAY_OF_WEEK; value DailyDataSet for every day of week
avg_data = new HashMap<Integer, DailyDataSet>(); //holds all the average data values; key: DAY_OF_WEEK; value DailyDataSet for every day of week
max_data = new HashMap<Integer, DailyDataSet>(); //holds all the max data values; key: DAY_OF_WEEK; value DailyDataSet for every day of week
}
public static BasicDataHandler getInstance() {
if (myself == null) {
myself = new BasicDataHandler();
}
return myself;
}
private void registerDailyDataSet(DailyDataSet ds) {
Calendar c = Calendar.getInstance();
c.setTime(ds.getDay());
Integer tmp = new Integer(c.get(Calendar.DAY_OF_MONTH));
data.put(tmp, ds);
}
private void registerCalcValueMinDailyDataSet(DailyDataSet ds) {
Calendar c = Calendar.getInstance();
c.setTime(ds.getDay());
Integer tmp = new Integer(c.get(Calendar.DAY_OF_WEEK));
min_data.put(tmp, ds);
}
private void registerCalcValueAvgDailyDataSet(DailyDataSet ds) {
Calendar c = Calendar.getInstance();
c.setTime(ds.getDay());
Integer tmp = new Integer(c.get(Calendar.DAY_OF_WEEK));
avg_data.put(tmp, ds);
}
private void registerCalcValueMaxDailyDataSet(DailyDataSet ds) {
Calendar c = Calendar.getInstance();
c.setTime(ds.getDay());
Integer tmp = new Integer(c.get(Calendar.DAY_OF_WEEK));
max_data.put(tmp, ds);
}
public void registerDataObject(DataObject dob) {
Calendar c = Calendar.getInstance();
c.setTime(dob.getTimeAsDate());
Integer key = c.get(Calendar.DAY_OF_MONTH);
DailyDataSet ds = data.get(key);
if(ds == null) {
registerDailyDataSet(new DailyDataSet(dob.getTimeAsDate()));
ds = data.get(key);
}
ds.addDataObject(dob);
Integer keyCalcValues = c.get(Calendar.DAY_OF_WEEK);
ds = min_data.get(keyCalcValues);
DataObject t;
if(ds == null) {
registerCalcValueMinDailyDataSet(new DailyDataSet(dob.getTimeAsDate()));
ds = min_data.get(keyCalcValues);
ds.addDataObject(new DataObject(dob.getTimeAsDate(),dob.getKwh(),DataObject.TYPE_MIN));
}else{
t = ds.getDataObjectByWeekday(dob.getTimeAsDate());
if(t==null) {
t=new DataObject(dob.getTimeAsDate(),dob.getKwh(),DataObject.TYPE_MIN);
ds.addDataObject(t);
}
if(t.getKwh()>dob.getKwh())
t.setKwh(dob.getKwh());
}
ds = avg_data.get(keyCalcValues);
if(ds == null) {
registerCalcValueAvgDailyDataSet(new DailyDataSet(dob.getTimeAsDate()));
ds = avg_data.get(keyCalcValues);
ds.addDataObject(new DataObject(dob.getTimeAsDate(),dob.getKwh(),DataObject.TYPE_AVG));
}else{
t = ds.getDataObjectByWeekday(dob.getTimeAsDate());
if(t==null) {
t=new DataObject(dob.getTimeAsDate(),dob.getKwh(),DataObject.TYPE_AVG);
ds.addDataObject(t);
}
if(t.getKwh()>dob.getKwh())
t.setKwh(dob.getKwh());
}
ds = max_data.get(keyCalcValues);
if(ds == null) {
registerCalcValueMaxDailyDataSet(new DailyDataSet(dob.getTimeAsDate()));
ds = max_data.get(keyCalcValues);
ds.addDataObject(new DataObject(dob.getTimeAsDate(),dob.getKwh(),DataObject.TYPE_MAX));
}else{
t = ds.getDataObjectByWeekday(dob.getTimeAsDate());
if(t==null) {
t=new DataObject(dob.getTimeAsDate(),dob.getKwh(),DataObject.TYPE_MAX);
ds.addDataObject(t);
}
if(t.getKwh()<dob.getKwh())
t.setKwh(dob.getKwh());
}
}
public List<DataObject> getThatBeanList() {
List<DataObject> rl = new ArrayList<DataObject>();
Iterator<Integer> iter = data.keySet().iterator();
Calendar c = Calendar.getInstance();
while (iter.hasNext()) {
Integer keyToDo = iter.next();
DailyDataSet dds = data.get(keyToDo);
rl.addAll(dds.getData());
c.setTime(dds.getDay());
Integer dayKey = c.get(Calendar.DAY_OF_WEEK);
DailyDataSet dsmin = min_data.get(dayKey);
rl.addAll(dsmin.getData());
DailyDataSet dsavg = avg_data.get(dayKey);
rl.addAll(dsavg.getData());
DailyDataSet dsmax = max_data.get(dayKey);
rl.addAll(dsmax.getData());
}
return rl;
}
}
DailyDataSet:
package sc2pdf.datasets;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import sc2pdf.javabeans.DataObject;
public class DailyDataSet {
private Date day;
private Collection<DataObject> data;
public DailyDataSet() {
this(new Date());
}
public DailyDataSet(Date d) {
this.day=d;
this.data = new ArrayList<DataObject>();
}
public void addDataObject(Date d, double k) {
this.data.add(new DataObject(d,k));
}
public void addDataObject(DataObject d) {
this.data.add(d);
}
public Date getDay() {
return day;
}
public Collection<DataObject> getData(){
return data;
}
public DataObject getDataObject(Date toSearch) {
Iterator<DataObject> iter = data.iterator();
Calendar c = Calendar.getInstance();
c.setTime(toSearch);
while (iter.hasNext()) {
DataObject dob = iter.next();
Calendar c2 = Calendar.getInstance();
c2.setTime(dob.getTimeAsDate());
if(c.equals(c2)) {
return dob;
}
}
return null;
}
public DataObject getDataObjectByWeekday(Date toSearch) {
Iterator<DataObject> iter = data.iterator();
Calendar c = Calendar.getInstance();
c.setTime(toSearch);
while (iter.hasNext()) {
DataObject dob = iter.next();
Calendar c2 = Calendar.getInstance();
c2.setTime(dob.getTimeAsDate());
if(c.get(Calendar.DAY_OF_WEEK) == c2.get(Calendar.DAY_OF_WEEK)) {
if(c.get(Calendar.HOUR_OF_DAY) == c2.get(Calendar.HOUR_OF_DAY)) {
if(c.get(Calendar.MINUTE) == c2.get(Calendar.MINUTE)) {
return dob;
}
}
}
}
return null;
}
}
DataObject:
package sc2pdf.javabeans;
import java.util.Calendar;
import java.util.Date;
public class DataObject {
private Date timeAsDate;
private Integer day;
private String timeAsString;
private double kwh;
private Integer type;
public static final Integer TYPE_DATA = 1;
public static final Integer TYPE_MIN = 2;
public static final Integer TYPE_AVG = 3;
public static final Integer TYPE_MAX = 4;
/**
* Constructor
*/
public DataObject() {
this(new Date(),0);
}
public DataObject(int day, int month, int year, int hour, int minute, double k) {
this(day,month,year,hour,minute,k,TYPE_DATA);
}
public DataObject(int day, int month, int year, int hour, int minute, double k, Integer typ) {
Calendar c = Calendar.getInstance();
c.set(year,month,day,hour,minute);
this.day=new Integer(c.get(Calendar.DAY_OF_MONTH));
this.timeAsDate=c.getTime();
this.kwh=k;
this.type=typ;
generateTimeAsString();
}
public DataObject(Date t, double p) {
this(t,p,TYPE_DATA);
}
public DataObject(Date t, double p, Integer ty) {
this.timeAsDate=t;
this.kwh=p;
this.type=ty;
Calendar c = Calendar.getInstance();
c.setTime(t);
this.day=new Integer(c.get(Calendar.DAY_OF_MONTH));
generateTimeAsString();
}
public void generateTimeAsString() {
Calendar c = Calendar.getInstance();
c.setTime(timeAsDate);
timeAsString = c.get(Calendar.HOUR_OF_DAY) +
":"+
c.get(Calendar.MINUTE);
}
public String getTime() {
return timeAsString != null?timeAsString:"WRONG STRING";
}
public void setTime(String s) {
this.timeAsString = s;
}
public Integer getDay() {
return day;
}
public void setDay(Integer day) {
this.day = day;
}
public double getKwh() {
return kwh;
}
public void setKwh(double kwh) {
this.kwh = kwh;
}
public Date getTimeAsDate() {
return timeAsDate;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String toString() {
return (type.equals(DataObject.TYPE_DATA)?"DATA: ":(type.equals(DataObject.TYPE_MIN)?" MIN: ":(type.equals(DataObject.TYPE_AVG)?" AVG: ":" MAX: ")))+this.timeAsDate.toString()+": "+this.kwh;
}
}
the data as it get delivered to the report (format: [type==1?"DATA: ":type==2?"MIN: ":type==3?"AVG: ":"MAX: "]+Date+kWh
DATA: Tue Jan 01 00:00:07 CET 2019: 2.501
DATA: Tue Jan 01 00:15:07 CET 2019: 2.679
DATA: Tue Jan 01 00:30:07 CET 2019: 2.93
DATA: Tue Jan 01 00:45:07 CET 2019: 2.363
DATA: Tue Jan 01 01:00:07 CET 2019: 2.589
DATA: Tue Jan 01 01:15:07 CET 2019: 2.423
DATA: Tue Jan 01 01:30:07 CET 2019: 2.531
DATA: Tue Jan 01 01:45:07 CET 2019: 2.976
DATA: Tue Jan 01 02:00:07 CET 2019: 2.369
DATA: Tue Jan 01 02:15:07 CET 2019: 2.636
DATA: Tue Jan 01 02:30:07 CET 2019: 2.391
DATA: Tue Jan 01 02:45:07 CET 2019: 2.667
DATA: Tue Jan 01 03:00:07 CET 2019: 2.88
DATA: Tue Jan 01 03:15:07 CET 2019: 2.378
DATA: Tue Jan 01 03:30:07 CET 2019: 2.723
DATA: Tue Jan 01 03:45:07 CET 2019: 2.511
DATA: Tue Jan 01 04:00:07 CET 2019: 2.789
DATA: Tue Jan 01 04:15:07 CET 2019: 2.867
DATA: Tue Jan 01 04:30:07 CET 2019: 3.101
DATA: Tue Jan 01 04:45:07 CET 2019: 3.321
DATA: Tue Jan 01 05:00:07 CET 2019: 2.438
DATA: Tue Jan 01 05:15:07 CET 2019: 2.616
DATA: Tue Jan 01 05:30:07 CET 2019: 3.146
DATA: Tue Jan 01 05:45:07 CET 2019: 5.882
DATA: Tue Jan 01 06:00:07 CET 2019: 4.814
DATA: Tue Jan 01 06:15:07 CET 2019: 4.593
DATA: Tue Jan 01 06:30:07 CET 2019: 5.078
DATA: Tue Jan 01 06:45:07 CET 2019: 5.69
DATA: Tue Jan 01 07:00:07 CET 2019: 9.734
DATA: Tue Jan 01 07:15:07 CET 2019: 12.63
DATA: Tue Jan 01 07:30:07 CET 2019: 14.304
DATA: Tue Jan 01 07:45:07 CET 2019: 14.52
DATA: Tue Jan 01 08:00:07 CET 2019: 14.988
DATA: Tue Jan 01 08:15:07 CET 2019: 14.984
DATA: Tue Jan 01 08:30:07 CET 2019: 14.748
DATA: Tue Jan 01 08:45:07 CET 2019: 13.859
DATA: Tue Jan 01 09:00:07 CET 2019: 12.038
DATA: Tue Jan 01 09:15:07 CET 2019: 15.084
DATA: Tue Jan 01 09:30:07 CET 2019: 14.787
DATA: Tue Jan 01 09:45:07 CET 2019: 15.069
DATA: Tue Jan 01 10:00:07 CET 2019: 15.764
DATA: Tue Jan 01 10:15:07 CET 2019: 16.71
DATA: Tue Jan 01 10:30:07 CET 2019: 15.549
DATA: Tue Jan 01 10:45:07 CET 2019: 14.21
DATA: Tue Jan 01 11:00:07 CET 2019: 14.073
DATA: Tue Jan 01 11:15:07 CET 2019: 12.233
DATA: Tue Jan 01 11:30:07 CET 2019: 13.17
DATA: Tue Jan 01 11:45:07 CET 2019: 11.973
DATA: Tue Jan 01 12:00:07 CET 2019: 11.982
DATA: Tue Jan 01 12:15:07 CET 2019: 10.907
DATA: Tue Jan 01 12:30:07 CET 2019: 8.087
DATA: Tue Jan 01 12:45:07 CET 2019: 4.575
DATA: Tue Jan 01 13:00:07 CET 2019: 2.96
DATA: Tue Jan 01 13:15:07 CET 2019: 1.884
DATA: Tue Jan 01 13:30:07 CET 2019: 0.995
DATA: Tue Jan 01 13:45:07 CET 2019: 2.691
DATA: Tue Jan 01 14:00:07 CET 2019: 1.826
DATA: Tue Jan 01 14:15:07 CET 2019: 2.487
DATA: Tue Jan 01 14:30:07 CET 2019: 2.984
DATA: Tue Jan 01 14:45:07 CET 2019: 2.808
DATA: Tue Jan 01 15:00:07 CET 2019: 3.539
DATA: Tue Jan 01 15:15:07 CET 2019: 2.49
DATA: Tue Jan 01 15:30:07 CET 2019: 3.473
DATA: Tue Jan 01 15:45:07 CET 2019: 6.41
DATA: Tue Jan 01 16:00:07 CET 2019: 6.977
DATA: Tue Jan 01 16:15:07 CET 2019: 6.854
DATA: Tue Jan 01 16:30:07 CET 2019: 12.807
DATA: Tue Jan 01 16:45:07 CET 2019: 10.83
DATA: Tue Jan 01 17:00:07 CET 2019: 8.435
DATA: Tue Jan 01 17:15:07 CET 2019: 8.633
DATA: Tue Jan 01 17:30:07 CET 2019: 4.887
DATA: Tue Jan 01 17:45:07 CET 2019: 3.594
DATA: Tue Jan 01 18:00:07 CET 2019: 3.36
DATA: Tue Jan 01 18:15:07 CET 2019: 4.145
DATA: Tue Jan 01 18:30:07 CET 2019: 9.11
DATA: Tue Jan 01 18:45:07 CET 2019: 8.714
DATA: Tue Jan 01 19:00:07 CET 2019: 7.982
DATA: Tue Jan 01 19:15:07 CET 2019: 6.545
DATA: Tue Jan 01 19:30:07 CET 2019: 6.764
DATA: Tue Jan 01 19:45:07 CET 2019: 7.394
DATA: Tue Jan 01 20:00:07 CET 2019: 9.887
DATA: Tue Jan 01 20:15:07 CET 2019: 7.292
DATA: Tue Jan 01 20:30:07 CET 2019: 5.972
DATA: Tue Jan 01 20:45:07 CET 2019: 6.924
DATA: Tue Jan 01 21:00:07 CET 2019: 6.426
DATA: Tue Jan 01 21:15:07 CET 2019: 5.675
DATA: Tue Jan 01 21:30:07 CET 2019: 5.973
DATA: Tue Jan 01 21:45:07 CET 2019: 5.936
DATA: Tue Jan 01 22:00:07 CET 2019: 6.06
DATA: Tue Jan 01 22:15:07 CET 2019: 5.646
DATA: Tue Jan 01 22:30:07 CET 2019: 4.484
DATA: Tue Jan 01 22:45:07 CET 2019: 2.481
DATA: Tue Jan 01 23:00:07 CET 2019: 2.49
DATA: Tue Jan 01 23:15:07 CET 2019: 2.423
DATA: Tue Jan 01 23:30:07 CET 2019: 2.49
DATA: Tue Jan 01 23:45:07 CET 2019: 2.955
MIN: Tue Jan 01 00:00:07 CET 2019: 2.154
MIN: Tue Jan 01 00:15:07 CET 2019: 2.093
MIN: Tue Jan 01 00:30:07 CET 2019: 2.052
MIN: Tue Jan 01 00:45:07 CET 2019: 2.126
MIN: Tue Jan 01 01:00:07 CET 2019: 2.139
MIN: Tue Jan 01 01:15:07 CET 2019: 2.171
MIN: Tue Jan 01 01:30:07 CET 2019: 2.162
MIN: Tue Jan 01 01:45:07 CET 2019: 2.178
MIN: Tue Jan 01 02:00:07 CET 2019: 2.049
MIN: Tue Jan 01 02:15:07 CET 2019: 2.033
MIN: Tue Jan 01 02:30:07 CET 2019: 2.034
MIN: Tue Jan 01 02:45:07 CET 2019: 2.129
MIN: Tue Jan 01 03:00:07 CET 2019: 2.159
MIN: Tue Jan 01 03:15:07 CET 2019: 2.165
MIN: Tue Jan 01 03:30:07 CET 2019: 2.001
MIN: Tue Jan 01 03:45:07 CET 2019: 2.006
MIN: Tue Jan 01 04:00:07 CET 2019: 2.313
MIN: Tue Jan 01 04:15:07 CET 2019: 1.992
MIN: Tue Jan 01 04:30:07 CET 2019: 2.082
MIN: Tue Jan 01 04:45:07 CET 2019: 1.982
MIN: Tue Jan 01 05:00:07 CET 2019: 2.217
MIN: Tue Jan 01 05:15:07 CET 2019: 2.088
MIN: Tue Jan 01 05:30:07 CET 2019: 2.09
MIN: Tue Jan 01 05:45:07 CET 2019: 1.923
MIN: Tue Jan 01 06:00:07 CET 2019: 1.928
MIN: Tue Jan 01 06:15:07 CET 2019: 2.337
MIN: Tue Jan 01 06:30:07 CET 2019: 2.333
MIN: Tue Jan 01 06:45:07 CET 2019: 2.397
MIN: Tue Jan 01 07:00:07 CET 2019: 2.135
MIN: Tue Jan 01 07:15:07 CET 2019: 2.45
MIN: Tue Jan 01 07:30:07 CET 2019: 2.288
MIN: Tue Jan 01 07:45:07 CET 2019: 2.405
MIN: Tue Jan 01 08:00:07 CET 2019: 2.093
MIN: Tue Jan 01 08:15:07 CET 2019: 2.403
MIN: Tue Jan 01 08:30:07 CET 2019: 3.309
MIN: Tue Jan 01 08:45:07 CET 2019: 2.904
and a screenshot from my output:
my pdf looks like this atm...
dummy cvs(separated by '|') valueset:
day|type|time|kwh
1|1|00:15|0.9
1|1|00:30|1.2
1|2|00:15|0.8
1|2|00:30|1
1|3|00:15|0.8
1|3|00:30|1.1
1|4|00:15|1
1|4|00:30|1.5
2|1|00:15|0.7
2|1|00:30|1
2|2|00:15|0.6
2|2|00:30|0.9
2|3|00:15|0.7
2|3|00:30|1
2|4|00:15|0.8
2|4|00:30|1.1
expected outcome (the red line would be data of type '1', the green of type'2', the blue of type'3' and the yellow of type'4'; there should be as many charts, as different days (which would be solved via grouping, which already works):
expected chart

SBT 0.12.1 downloads wrong SNAPSHOT

I deploy some SNAPSHOT dependencies to Sonatype OSS using mvn. Sonatype stores a number of old snapshots for each coordinate. A directory listing of my deployed SNAPSHOTs is at the bottom of this question.
In my sbt Play! project, I added the Sonatype SNAPSHOT repository as a resolver.
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
// Add your own project settings here
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
)
However, the wrong SNAPSHOT is downloaded each time. While sbt should download the last deployed SNAPSHOT (20130109.225335-6) but it downloads the first deployed SNAPSHOT (20130109.210948-1).
$ rm -r ~/.ivy2/cache/edu.washington.cs.knowitall.chunkedextractor/
$ sbt clean compile
[info] Loading project definition from /scratch/github/knowitall/documentextractor/project
[info] Set current project to documentextractor (in build file:/scratch/github/knowitall/documentextractor/)
[success] Total time: 0 s, completed Jan 9, 2013 3:06:41 PM
[info] Updating {file:/scratch/github/knowitall/documentextractor/}documentextractor...
[info] downloading http://repo.typesafe.com/typesafe/snapshots/edu/washington/cs/knowitall/chunkedextractor/chunkedextractor_2.9.2/1.0.1-SNAPSHOT/chunkedextractor_2.9.2-1.0.1-20130109.210948-1.jar ...
[info] [SUCCESSFUL ] edu.washington.cs.knowitall.chunkedextractor#chunkedextractor_2.9.2;1.0.1-SNAPSHOT!chunkedextractor_2.9.2.jar (1079ms)
[info] Done updating.
Any idea how I can fix this and make sbt download the most recent SNAPSHOT? Is this an sbt-specific problem or does it have to do with Play!?
Here is the directory listing of my artifact's snapshots on Sonatype.
https://oss.sonatype.org/content/repositories/snapshots/edu/washington/cs/knowitall/chunkedextractor/chunkedextractor_2.9.2/1.0.1-SNAPSHOT/
chunkedextractor_2.9.2-1.0.1-20130109.210948-1-javadoc.jar Wed Jan 09 15:09:55 CST 2013 361379
chunkedextractor_2.9.2-1.0.1-20130109.210948-1-javadoc.jar.md5 Wed Jan 09 15:09:56 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.210948-1-javadoc.jar.sha1 Wed Jan 09 15:09:56 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.210948-1-sources.jar Wed Jan 09 15:09:53 CST 2013 17175
chunkedextractor_2.9.2-1.0.1-20130109.210948-1-sources.jar.md5 Wed Jan 09 15:09:54 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.210948-1-sources.jar.sha1 Wed Jan 09 15:09:53 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.210948-1.jar Wed Jan 09 15:09:48 CST 2013 178994
chunkedextractor_2.9.2-1.0.1-20130109.210948-1.jar.md5 Wed Jan 09 15:09:49 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.210948-1.jar.sha1 Wed Jan 09 15:09:49 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.210948-1.pom Wed Jan 09 15:09:49 CST 2013 3725
chunkedextractor_2.9.2-1.0.1-20130109.210948-1.pom.md5 Wed Jan 09 15:09:50 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.210948-1.pom.sha1 Wed Jan 09 15:09:50 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.222121-2-javadoc.jar Wed Jan 09 16:21:29 CST 2013 363291
chunkedextractor_2.9.2-1.0.1-20130109.222121-2-javadoc.jar.md5 Wed Jan 09 16:21:30 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.222121-2-javadoc.jar.sha1 Wed Jan 09 16:21:30 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.222121-2-sources.jar Wed Jan 09 16:21:27 CST 2013 17195
chunkedextractor_2.9.2-1.0.1-20130109.222121-2-sources.jar.md5 Wed Jan 09 16:21:27 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.222121-2-sources.jar.sha1 Wed Jan 09 16:21:27 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.222121-2.jar Wed Jan 09 16:21:21 CST 2013 177267
chunkedextractor_2.9.2-1.0.1-20130109.222121-2.jar.md5 Wed Jan 09 16:21:22 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.222121-2.jar.sha1 Wed Jan 09 16:21:22 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.222121-2.pom Wed Jan 09 16:21:23 CST 2013 3725
chunkedextractor_2.9.2-1.0.1-20130109.222121-2.pom.md5 Wed Jan 09 16:21:23 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.222121-2.pom.sha1 Wed Jan 09 16:21:23 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.223017-3-javadoc.jar Wed Jan 09 16:30:25 CST 2013 363291
chunkedextractor_2.9.2-1.0.1-20130109.223017-3-javadoc.jar.md5 Wed Jan 09 16:30:26 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.223017-3-javadoc.jar.sha1 Wed Jan 09 16:30:25 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.223017-3-sources.jar Wed Jan 09 16:30:22 CST 2013 17195
chunkedextractor_2.9.2-1.0.1-20130109.223017-3-sources.jar.md5 Wed Jan 09 16:30:23 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.223017-3-sources.jar.sha1 Wed Jan 09 16:30:23 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.223017-3.jar Wed Jan 09 16:30:18 CST 2013 177267
chunkedextractor_2.9.2-1.0.1-20130109.223017-3.jar.md5 Wed Jan 09 16:30:18 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.223017-3.jar.sha1 Wed Jan 09 16:30:18 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.223017-3.pom Wed Jan 09 16:30:19 CST 2013 3725
chunkedextractor_2.9.2-1.0.1-20130109.223017-3.pom.md5 Wed Jan 09 16:30:19 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.223017-3.pom.sha1 Wed Jan 09 16:30:19 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.224717-4-javadoc.jar Wed Jan 09 16:47:24 CST 2013 363343
chunkedextractor_2.9.2-1.0.1-20130109.224717-4-javadoc.jar.md5 Wed Jan 09 16:47:24 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.224717-4-javadoc.jar.sha1 Wed Jan 09 16:47:24 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.224717-4-sources.jar Wed Jan 09 16:47:21 CST 2013 17198
chunkedextractor_2.9.2-1.0.1-20130109.224717-4-sources.jar.md5 Wed Jan 09 16:47:22 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.224717-4-sources.jar.sha1 Wed Jan 09 16:47:22 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.224717-4.jar Wed Jan 09 16:47:17 CST 2013 177369
chunkedextractor_2.9.2-1.0.1-20130109.224717-4.jar.md5 Wed Jan 09 16:47:18 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.224717-4.jar.sha1 Wed Jan 09 16:47:17 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.224717-4.pom Wed Jan 09 16:47:18 CST 2013 3725
chunkedextractor_2.9.2-1.0.1-20130109.224717-4.pom.md5 Wed Jan 09 16:47:19 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.224717-4.pom.sha1 Wed Jan 09 16:47:18 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.225244-5-javadoc.jar Wed Jan 09 16:52:52 CST 2013 363343
chunkedextractor_2.9.2-1.0.1-20130109.225244-5-javadoc.jar.md5 Wed Jan 09 16:52:52 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.225244-5-javadoc.jar.sha1 Wed Jan 09 16:52:52 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.225244-5-sources.jar Wed Jan 09 16:52:49 CST 2013 17198
chunkedextractor_2.9.2-1.0.1-20130109.225244-5-sources.jar.md5 Wed Jan 09 16:52:50 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.225244-5-sources.jar.sha1 Wed Jan 09 16:52:50 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.225244-5.jar Wed Jan 09 16:52:45 CST 2013 177369
chunkedextractor_2.9.2-1.0.1-20130109.225244-5.jar.md5 Wed Jan 09 16:52:46 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.225244-5.jar.sha1 Wed Jan 09 16:52:45 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.225244-5.pom Wed Jan 09 16:52:46 CST 2013 3725
chunkedextractor_2.9.2-1.0.1-20130109.225244-5.pom.md5 Wed Jan 09 16:52:47 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.225244-5.pom.sha1 Wed Jan 09 16:52:46 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.225335-6-javadoc.jar Wed Jan 09 16:53:42 CST 2013 363343
chunkedextractor_2.9.2-1.0.1-20130109.225335-6-javadoc.jar.md5 Wed Jan 09 16:53:43 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.225335-6-javadoc.jar.sha1 Wed Jan 09 16:53:42 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.225335-6-sources.jar Wed Jan 09 16:53:40 CST 2013 17198
chunkedextractor_2.9.2-1.0.1-20130109.225335-6-sources.jar.md5 Wed Jan 09 16:53:40 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.225335-6-sources.jar.sha1 Wed Jan 09 16:53:40 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.225335-6.jar Wed Jan 09 16:53:35 CST 2013 177369
chunkedextractor_2.9.2-1.0.1-20130109.225335-6.jar.md5 Wed Jan 09 16:53:36 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.225335-6.jar.sha1 Wed Jan 09 16:53:36 CST 2013 40
chunkedextractor_2.9.2-1.0.1-20130109.225335-6.pom Wed Jan 09 16:53:36 CST 2013 3725
chunkedextractor_2.9.2-1.0.1-20130109.225335-6.pom.md5 Wed Jan 09 16:53:37 CST 2013 32
chunkedextractor_2.9.2-1.0.1-20130109.225335-6.pom.sha1 Wed Jan 09 16:53:37 CST 2013 40
maven-metadata.xml Wed Jan 09 16:53:43 CST 2013 1244
maven-metadata.xml.md5 Wed Jan 09 16:53:44 CST 2013 32
maven-metadata.xml.sha1 Wed Jan 09 16:53:43 CST 2013 40
UPDATE: build.properties specifies sbt.version=0.11.3. Maybe Play is forcing this older version of sbt.
Try if one of these might help you:
1) run 'update'
2) modify dependency to "groupId" %% "artifactId" % "version" changing() and run 'update'