title: Map to avoid Duplicate records
body: <blockquote>
    <p>I have a Holiday Custom object,it contains Unique Dates based on
    country based How to retrieve the value in Map</p>
  </blockquote>
  
  <p>I have tried:</p>
  
  <pre><code> List&lt;Holiday__c&gt; holidays = new List&lt;Holiday__c&gt;([Select id, Date__c,Country__c from Holiday__c]);
  
      Map&lt;date, Holiday__c&gt; mapOfHolidays = new Map&lt;date, Holiday__c&gt;(); 
      for (Holiday__c holiday: holidays)  mapOfHolidays.put(holiday.Date__c , holiday); 
  </code></pre>
  
  <p>Suppose date for example 3/8/17 is for country france and Italy,If i put Key Value as Date__c,Map does not contain Key as duplicates,But for each country unique Dates are there</p>
  
  <p><strong>So what i have to use Key and Value in Map,I want to retrieve the date using Map,please anyone Help for me the answer</strong></p>
  
  <pre><code>trigger ignoreweekends on order (before insert,before update) {
  
      Set&lt;id&gt; accountIds = new Set&lt;Id&gt;();
      for (order ord : Trigger.new) {
          accountids.add(ord.AccountId);
      }
  
      map&lt;id, account&gt; mapOfAccounts = new map&lt;id, account&gt;([select id,JDE_Date_Delivery_Offset__c from account where id IN: accountIds]);
  
      List&lt;Holiday__c&gt; holidays = new List&lt;Holiday__c&gt;([Select id, Date__c from Holiday__c]);
  
      Map&lt;date, Holiday__c&gt; mapOfHolidays = new Map&lt;date, Holiday__c&gt;(); 
      for (Holiday__c holiday: holidays)  mapOfHolidays.put(holiday.Date__c , holiday); 
  
      for (order so : Trigger.new) {
          Account acc = mapOfAccounts.get(so.AccountId); 
          for(integer i=0;i&lt;=acc.JDE_Date_Delivery_Offset__c;i++) {
              Datetime dt = DateTime.newInstance(Date.today() +acc.JDE_Date_Delivery_Offset__c.longvalue(), Time.newInstance(0, 0, 0, 0));
              String dayOfWeek=dt.format('EEEE');
  
              if(dayOfWeek == 'saturday' || dayOfWeek == 'sunday'|| mapOfHolidays.containskey(mapOfHolidays.Date__c))  
  
              acc.JDE_Date_Delivery_Offset__c = acc.JDE_Date_Delivery_Offset__c+ 1;
  
              so.JDE_Synchronization_Date__c = Date.today().addDays(acc.JDE_Date_Delivery_Offset__c.intValue());
          }
      }
  }
  </code></pre>