function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
revathyrevathy 

Map<string,list<Date>> its possible to do it?

I have samll clarifications how to use  Map<string,list<Date>> like that?
My scenario is :i have two fields Dealer number,Date from soql query i got the values below that.
Date ------     Dealer number
10/02/2017    10100
15/01/2017    10100
02/02/2017    10100

01/02/2017    10101
05/02/2017    10101
10/01/2017    10102
31/01/2017    10102

I want output based on Dealer number.see one Dealer having different dates.this Dealer 10100 having 3 different dates,Month of JAN(count is 1) and Month Feb(count is 2).count is calucuted based on same month based. 
output should be:

Dealer-----FebMonth(Count)-----JanMonth(Count)
10100 ----------------2-----------1

please guide me how to achive this scenario?

Advanced thanks
Raj VakatiRaj Vakati
Hi Revathy , 

Please find sample code here 

Map<String,List<Date>> mapOf =new  Map<String,List<Date>>()
    If(mapOf.containsKey('Key')){
        mapOf.get('Key').add(new Date());
    }else{
        mapOf.put('Key' , new List<Date>{newDate})
            }


 
AnjunaAnjuna
Hi Revathy,
you can use Map<string,list<Date>> for your functionality.
Please find the sample code below.
Map<string,list<Date>> dealerDetailMap = new Map<string,list<Date>>();
for(iterate your records here) {
     if(dealerDetailMap .contaiskey(dealerNumber)) {
            dealerDetailMap .get(dealerNumber).add(DateVal);
     } else{
            dealerDetailMap .put(dealerNumber,new List<Date>{DateVal});
     }
}