title: Convert a Regular Date to Julian Date and vice versa in Java
body: <p>I've written a simple code that converts a regular date to Julian date.</p>
  
  <p>Here's the code for those who need the same conversion: </p>
  
  <pre><code>    public int convertToJulian(String unformattedDate)
      {
      /*Unformatted Date: ddmmyyyy*/
      int resultJulian = 0;
      if(unformattedDate.length() &gt; 0)
      {
       /*Days of month*/
       int[] monthValues = {31,28,31,30,31,30,31,31,30,31,30,31};
  
       String dayS, monthS, yearS;
       dayS = unformattedDate.substring(0,2);
       monthS = unformattedDate.substring(3, 5);
       yearS = unformattedDate.substring(6, 10);
  
       /*Convert to Integer*/
       int day = Integer.valueOf(dayS);
       int month = Integer.valueOf(monthS);
       int year = Integer.valueOf(yearS); 
  
           //Leap year check
           if(year % 4 == 0)
           {
            monthValues[1] = 29;    
           }
           //Start building Julian date
           String julianDate = "1";
           //last two digit of year: 2012 ==&gt; 12
           julianDate += yearS.substring(2,4);
  
           int julianDays = 0;
           for (int i=0; i &lt; month-1; i++)
           {
            julianDays += monthValues[i];
           }
           julianDays += day;
  
               if(String.valueOf(julianDays).length() &lt; 2)
               {
                julianDate += "00";
               }
               if(String.valueOf(julianDays).length() &lt; 3)
               {
                julianDate += "0";
               }
  
          julianDate += String.valueOf(julianDays);
      resultJulian =  Integer.valueOf(julianDate);    
   }
   return resultJulian;
  }
  </code></pre>
  
  <p>This code converts 01.01.2013 to 113001</p>
  
  <p>What I want to do is to convert a Julian date to regular date without time details. 
  For example: Julian date is 113029 ==> Regular date 29.01.2013  </p>
  
  <p>Please give me your ideas on how to do it.</p>
  
  <p>Thanks.</p>