title: How to replace a date in GMT format with current date value in a String
body: <p>I have a json string as below and I need to replace the datetime value with the current value . I have the datetime value from the string in one variable for e.g Date1 , and I have current date in another variable Date2 . I need java code to replace whole date , I know how to replace one word but here we have space in between the date and time so multiple words .</p>
  <pre><code> Date1 = Mon, 13 Jul 2020 14:08:30 GMT
   Date2 = Wed, 15 Jul 2020 19:58:16 GMT
   String  json = {
        &quot;timestamp&quot;: [
                {
                  &quot;componentName&quot;: &quot;docker-sam&quot;,
                  &quot;datetime&quot;: &quot;Mon, 13 Jul 2020 14:08:30 GMT&quot;
                }
              ]
            &quot;Id&quot;: &quot;docker-sam&quot;,
            &quot;sourceId&quot;: &quot; &quot;,      
      }    
  </code></pre>
  <p>I am doing :</p>
  <pre><code>vNewJson = json.replace(Date1,Date2); 
  </code></pre>
  <p>But new Date2 is not getting replaced .
  Could anybody please suggest how to replace multiple words value in above case .
  Below is my code :</p>
  <pre><code>    String[] Valuepair2 = vJson.split(&quot;datetime&quot;);
      String vDate12 = Valuepair2[1].substring(2,Valuepair2[1].length());
      String[] Valuepair3 = vDate12.split(&quot;GMT&quot;);             
      String vDate = Valuepair3[0] + &quot; &quot; + &quot;GMT&quot;;
      System.out.println(vDate);
      String vDate1 = vDate.substring(2,vDate.length()); //remove curly
      System.out.println(&quot;Value pair 0---&gt;&gt;&quot; + vDate1);                   
      StartEpochValue = vDate1;                   
      DateTimeFormatter dtf = DateTimeFormatter.RFC_1123_DATE_TIME;
      ZonedDateTime zdt = ZonedDateTime.now(ZoneId.of(&quot;GMT&quot;));
      String Date2 = (dtf.format(zdt)).toString();
      System.out.println(&quot;Date 2 ==&quot; + Date2);
      System.out.println(vJsonfile1);
      vPublishJsonfile1 = vJson.replace(vDate1,Date2);    
  </code></pre>