title: Writing dates in csv files, some output as ######
body: <p>I am writing an application where I let some threads write csv files with random numbers and random dates. However, some of the dates output as ######, but when I click them in Excell, they do show the correct date (e.g.11/4/2014 shows as ###### in Excell, but when I click on this cell, in the fx field it does show as 11/4/2014). </p>
  
  <p>Here is how I write my dates:</p>
  
  <pre><code>    Random random = new Random();
      BufferedWriter bufferedWriter;
      GregorianCalendar cal = new GregorianCalendar();
      DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
  
  
      writeLine(random, bufferedWriter, cal, df);
  
  private void writeLine(Random random, BufferedWriter bufferedWriter, GregorianCalendar cal, DateFormat df) throws IOException {
          String randomDateString;
          bufferedWriter.write(Double.toString(random.nextDouble() * 100));
          bufferedWriter.write(",");
          randomDateString = createRandomDate(random, cal, df);
          bufferedWriter.write(randomDateString);
          bufferedWriter.newLine();
      }
  
   private String createRandomDate(Random random, GregorianCalendar cal, DateFormat df) {
          int randomDayOfTheYear;
          Date randomDate;
          String randomDateString;
          randomDayOfTheYear = random.nextInt(365) + 1;
          cal.set(Calendar.YEAR, 2014);
          cal.set(Calendar.DAY_OF_YEAR, randomDayOfTheYear);
          randomDate = cal.getTime();
          randomDateString = df.format(randomDate);
          return randomDateString;
      }
  </code></pre>