Java Decimal Format Julian_Cal(double JDN)

Here you can find the source of Julian_Cal(double JDN)

Description

Julia Cal

License

Open Source License

Parameter

Parameter Description
JDN a parameter

Declaration

public static String Julian_Cal(double JDN)

    

Method Source Code

//package com.java2s;
/*/* w ww.  j  ava  2 s  .c o m*/
 * Created on Oct 23, 2003
 *
 * Copyright (c) 2005 Derone Bryson
 *
 * This program is free software; you can redistribute it and/or modify it under 
 * the terms of the GNU General Public License as published by the Free Software 
 * Foundation; either version 2, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with 
 * this software; see the file COPYING. If not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 * 
 * As a special exception, Derone Bryson and the StopMojo Project gives 
 * permission for additional uses of the text contained in its release of 
 * StopMojo.
 *
 * The exception is that, Derone Bryson and the the StopMojo Project hereby 
 * grants permission for non-GPL compatible modules (jar files, libraries, 
 * codecs, etc.) to be used and distributed together with StopMojo. This 
 * permission is above and beyond the permissions granted by the GPL license 
 * StopMojo is covered by.
 *
 * This exception does not however invalidate any other reasons why the 
 * executable file might be covered by the GNU General Public License.
 *
 * This exception applies only to the code released by Derone Bryson and/or the
 * StopMojo Project under the name StopMojo. If you copy code from other Free 
 * Software Foundation releases into a copy of StopMojo, as the General Public 
 * License permits, the exception does not apply to the code that you add in 
 * this way. To avoid misleading anyone as to the status of such modified files, 
 * you must delete this exception notice from them.
 *
 * If you write modifications of your own for StopMojo, it is your choice 
 * whether to permit this exception to apply to your modifications. If you do 
 * not wish that, delete this exception notice.  
 */

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class Main {
    /**
     * 
     * @param JDN
     * @return
     */
    public static String Julian_Cal(double JDN)
    /*
     * Returns a calendar date string in the standard form MM/DD/YY from the
     * Julian real parameter JDN.
     */
    { /* Julian_Cal */
        int D, /* Temporary variables */
                Y, M;

        double N1, N2, Y1, M1;

        N1 = (JDN - 1721119.0) + 2.0;
        Y1 = Math.floor((N1 - 0.2) / 365.25);
        N2 = N1 - Math.floor(365.25 * Y1);
        M1 = Math.floor((N2 - 0.5) / 30.6);
        D = (int) (N2 - 30.6 * M1 + 0.5);
        if (M1 > 9)
            Y1 += 1.0;
        Y = (int) Y1;
        if (M1 > 9)
            M1 -= 12;
        M = (int) (M1 + 3);
        /* Offset for the 20th century */
        if (Y > 1999)
            Y -= 2000;
        else
            Y -= 1900;

        NumberFormat nf = NumberFormat.getInstance();

        if (nf instanceof DecimalFormat)
            ((DecimalFormat) nf).applyPattern("00");

        return nf.format(M) + "/" + nf.format(D) + "/" + nf.format(Y);
    }
}

Related

  1. getValue(double value)
  2. isDouble(String _str)
  3. isLikelyDouble(long value)
  4. isprime(double x)
  5. isValidDouble(String value, int decimals)
  6. listToString(List list)
  7. numToString(double num)
  8. pad(double n)
  9. padding(final double number)