title: How do I set the format by the classmethod "setFormat" in main?
body: <p>How do I set the format for a date by my classmethod "setFormat" in main? I have a test file where I write "d1.toString();" and other things Before. What I want is to be able to set the date format to either american format or Swedish format in the test file and see the result.</p>
  
  <pre><code>    public static void setFormat(int theFormat)
      {
  
          format = theFormat;
  
      }
  
      public String toString()
      {
  
  
          if(format == SE_FORMAT)
          {
              date2 = Integer.toString(Year) + '-' + Integer.toString(Month) + '-' + Integer.toString(Day);
          }
          else if(theFormat == US_FORMAT)
          {
              date2 =  Integer.toString(Month) + '/' + Integer.toString(Day)  + '/' + Integer.toString(Year);
          }
          else
          {
              date2 = Integer.toString(Year) + '-' + Integer.toString(Month) + '-' + Integer.toString(Day);
          }
  
          return date2;
  
      }
  </code></pre>