1 Reply Latest reply: Feb 17, 2004 9:31 AM by 807582 RSS

    how to convert julian Date into Calendar Date

    807582
      Hi,

      I want convert julian Date to calendar Date (mm/dd/yyyy or mm/dd/yy format) in java.
      Can any one help me how to convert julian date to calendar Date.

      Thanks,
      Krishore.
        • 1. Re: how to convert julian Date into Calendar Date
          807582
          import java.util.*;
          import java.text.*;

          public class jdate {

          Calendar date;

          public jdate(int j)
          {
          date = Calendar.getInstance();

          date.set(Calendar.DAY_OF_YEAR, j);
          }

          public String toString()
          {
          SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");

          return (formatter.format( date.getTime() ));
          }

          public static void main(String args[])
          {
          if(args.length == 1)
          {
          int j = Integer.parseInt(args[0]);

          jdate julian = new jdate(j);
          System.out.println("Julian date(" + j + ") = " + julian.toString());
          }
          }
          }