Nested Mapping in Java
<p>I have the following data fetched from DB.</p>

<pre><code>Date                Name        users
-----               -------     ------
2016-11-23 00:00:00 aaaa        11
2016-11-24 00:00:00 aaaa        12
2016-11-25 00:00:00 aaaa        14
2016-11-24 00:00:00 bbbb        21
2016-11-26 00:00:00 bbbb        22
2016-11-23 00:00:00 cccc        31
2016-11-25 00:00:00 cccc        32
</code></pre>

<p>The data is fetched from a postgresql using GoogleAnalyticsPropertyDTO</p>

<p>I need to move it to a ListSeries (of size 11 to hold data for each day from 20-Nov to 30-Nov) such that </p>

<p>Expected result:</p>

<pre><code>result[0] = new ListSeries("aaa"    , new Number[] { 0,0,0,11,12,14,0,0,0,0,0});
result[1] = new ListSeries("bbb"    , new Number[] { 0,0,0,0,21,22,0,0,0,0,0 });
result[2] = new ListSeries("ccc"    , new Number[] { 0,0,0,31,0,32,0,0,0,0,0 });
</code></pre>

<p>I tried <code>Map&lt;Date, GoogleAnalyticsPropertyDTO&gt; map = new HashMap&lt;Date, GoogleAnalyticsPropertyDTO&gt;();</code> 
but getting only users value of the last series for each date. Can someone help me with a mapping with Date and the Name value together so as to do a mapping for my expected list series? Can MultiMap be used for this ?</p>

<p>The code which I tried with </p>

<pre><code>private Number[] getData(Date fromDate, Date toDate) {
        Date from = DateUtility.getDateWithoutTime(fromDate.getTime());
        Date to = DateUtility.getDateWithoutTime(toDate.getTime());
        Number[] result;
        int days = DateUtility.getDaysBetweenDates(from, to);
        result = new Number[days];

        List&lt;GoogleAnalyticsPropertyDTO&gt; gaPropList = XXXXXUI.getBusinessService().getGAProperty(fromDate, toDate);
        Map&lt;Date, GoogleAnalyticsPropertyDTO&gt; map = new HashMap&lt;Date, GoogleAnalyticsPropertyDTO&gt;();
        if (gaPropList != null) {
            for (GoogleAnalyticsPropertyDTO gaProperty : gaPropList) {
                Date dateString = gaProperty.getFromDate();
                map.put(dateString, gaProperty);
            }
            Date date;
            for (int d = 0; d &lt; days; d++) {
                date = DateUtility.addNDaysToDate(from, d);
                if (null == map.get(date)) {
                    result[d] = 0;
                } else {
                    GoogleAnalyticsPropertyDTO a = (GoogleAnalyticsPropertyDTO) map.get(date);
                   if (null == a.getUsers()) {
                       result[d] = 0;
                   } else {
                        result[d] = a.getUsers();
                  }
                }
            }
        }   
        return result;
    }
</code></pre>