title: Java previous day convert to unix , yesterday format
body: <p>I have a Java program for yesterday's date and perform it on Unix. but my program is not working. The main point, every day I should to call date format <code>yyMMdd</code> and then I will use this date format to collect user logs. The output should be for example <code>193007</code>.</p>
  
  <pre class="lang-java prettyprint-override"><code>import java.io.*;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  import java.util.Calendar;
  
  Calendar cal = Calendar.getInstance();
  cal.add(Calendar.DAY_OF_MONTH, -1);
  Date yesterday = cal.getTime();
  SimpleDateFormat formattedDate = new SimpleDateFormat("yyMMdd");
  formattedYesterday = formattedDate.format(yesterday);
  </code></pre>