1 Reply Latest reply: Mar 6, 2007 1:44 PM by 807596 RSS

    Convert Julian to Gregorian date

    807596
      Hi,

      I am having some trouble converting a Julian date to a Gregorian one or to a String of type : dd-MM-yyyy hh:mm:ss a

      The input format of my julian date is a string : 2007030020859574

      Any idea?

      Thx
        • 1. Re: Convert Julian to Gregorian date
          807596
          For what it is worth, here is a class format a String yyyyDDDHHmmssSSS (Julian format) into a diaplay format :

          package com.desj.visa.test;

          import java.util.GregorianCalendar;
          import java.util.Locale;

          import com.desj.visa.infra.util.UtilDate;

          /**
          * Classe pour tester la manipulation des dates en format julien
          *
          * @author Robin pelletier
          */

          public class Julien {
          /**
          * Constructeur pour �liminer un warning Checkstyle
          */
          private Julien() {
          }

          /**
          * M�thode main.
          *
          * @param args Param�tres
          */
          public static void main(final String[] args) {
          GregorianCalendar gc;
          String dateIn;
          String dateOut;
          String heureOut;

          for (int i = 2007000; i < 2007370; i++) {
          dateIn = Integer.toString(i) + "131546252";

          try {
          gc = UtilDate.string2GregCal(dateIn, "yyyyDDDHHmmssSSS");

          dateOut = UtilDate.gregCal2String(UtilDate.FORMAT_JJ_MMM_AAAA, gc, Locale.CANADA);
          heureOut = UtilDate.gregCal2String("HH:mm:ss,SSS", gc, Locale.CANADA_FRENCH);
          System.out.print(dateIn + " / ");
          System.out.print(dateOut + " / ");
          System.out.println(heureOut);

          } catch (Exception e) {
          e.printStackTrace();
          }
          }
          }
          }