anil
Java code
Posted in : Java Beginners

December 12, 2009 at 4:18 PM

Hi Friend,

Try the following code:

import java.util.*;
import java.text.DateFormatSymbols;

public class ConvertJulToGeo {
public static int greg= 15 + 31*(10+12*1582);
public static double convertToJulian(int[] ymd) {
int year=ymd[0];
int month=ymd[1];
int day=ymd[2];
int jyear = year;
int jmonth = month;
if (year < 0) jyear++;

if (month > 2) {
jmonth++;
}
else {
jyear--;
jmonth += 13;
}
double julianValue = (java.lang.Math.floor(365.25 * jyear)+ java.lang.Math.floor(30.6001*jmonth) + day + 1720995.0);
if (day + 31 * (month + 12 * year) >= greg) {
int value = (int)(0.01 * jyear);
julianValue += 2 - value + (0.25 * value);
}
return Math.floor(julianValue);
}
public static String[] convertToGregorian(double injulian) {
double sec = 0.5;
int j,j1,j2,j3,j4,j5,year,month,day;
double julian = injulian + sec / 86400.0;
j1 = (int) injulian;
if (j1>= greg) {
j = (int) (((j1 - 1867216) - 0.25) / 36524.25);
j1 = j1 + 1 + j - j / 4;
}
j2 = j1 + 1524;
j3 = (int) (6680.0 + ((j2 - 2439870) - 122.1) / 365.25);
j4 = 365 * j3 + j3 / 4;
j5 = (int) ((j2 - j4) / 30.6001);
day = j2 - j4 - (int) (30.6001 * j5);
month = j5 - 1;
if (month > 12) month = month - 12;
year = j3 - 4715;
if (month > 2) year--;
if (year <= 0) year--;
String mon=new DateFormatSymbols().getMonths()[month-1];
String dd=Integer.toString(day);
String y=Integer.toString(year);
return new String[] {mon, dd, y};
}
public static void main(String args[]) {
GregorianCalendar today = new GregorianCalendar();
double todayDate = convertToJulian(new int[]{today.get(Calendar.YEAR), today.get(Calendar.MONTH)+1,today.get(Calendar.DATE)});
System.out.println("Today's julian Date is : " + todayDate);
String []date = convertToGregorian(todayDate);
System.out.println("Today's Gregorian Date is : " + date[0] + "," + date[1] + "," + date[2]);
}
}

Hope that it will be helpful for you.
Thanks

JAVA code For
JAVA code For   JAVA code For "Traffic signals Identification for vehicles
java code
java code  write a java code to convert hindi to english using arrays
JAVA CODE
JAVA CODE  JAVA SOURCE CODE TO BLOCK A PARTICULAR WEB SITES(SOCIAL WEB SITE
java code
java code  what is the code to turn off my pc through java program
java code
java code  hi any one please tell me the java code to access any link i mean which method of which class is used to open any link in java program
java code
java code  sir how to merge the cells in excel using java code please help me and also how to make the text placed in the cell to be center
java code
java code  sir how to merge the cells in excel using java code please help me and also how to make the text placed in the cell to be center
java code
java code  write a java code for finding a string in partiular position in a delimited text file and replace the word with the values given by user and write the file in new location
java code
java code  need java code for chart or graph which compare the performance of aprior algorithm and coherent rule algorithm.plz any one help me out
java code
java code  I need the java code that would output the following: HARDWARE ITEMS CODE DESCRIPTION UNIT PRICE K16 Wood screws,brass,20mm \$7.75 D24 Wood glue,clear,1 liter \$5.50 M93
Java code
Java code   Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes
java code
java code  develop a banking system in java
java code
java code  HOW TO PRINT 1 TO 100 WITHOUT USING CONDITIONAL,ANY LOOP AND ARRAY IN JAVA AND C.URGENT SIR PLZ  Hi, You can use following code: class MyClass { public static void main(String[] args) { int
java code
java code  how to extract html tags using java
java code
java code  int g() { System.out.println("Inside method g"); int h() { System.out.println("Inside method h"); } } Find the error in the following... cannot define a method inside another method. Anyways, we have modified your code
Java code
Java code  Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any... the following code: import java.util.*; import java.text.*; class NumberProgram
java code
java code  what is meaning bufferedreader
java code
java code  what is meaning bufferedreader
Java code
Java code  An old-style movie theater has a simple profit program. Each customer pays \$5 per ticket. Every performance costs the theater \$20, plus...; Hi Friend, Try the following code: import java.util.*; import
Java code
Java code   Create a calculator class which will have methods add, multiply, divide & subtract   Hi Friend, Try the following code: class Calculation{ public int add(int a,int b){ return a+b
java code
java code  i want HSVcolor descriptor for color image in java coding
java code
java code  hi, Can any one tell me " How to read the data which is present om an image in java
Java Code
Java Code  Write a java program, which creates multiple threads. Each thread performs add/delete/update operations on an ArrayList simultaneously
java code
java code  I am beginer in java my question is how can i fill data from mysql database to jcombobox using netbeans
java code
java code  Write a program in java for lru caching using two inputs one using integer and another using string of uppercase only
Java code
Java code  Create a class called Student which has the following methods: i. Average: which would accept marks of 3 examinations & return... & returns the name.   Hi Friend, Try the following code: import
Java code
Java code  Create a Bank class with methods deposit & withdraw. The deposit method would accept attributes amount & balance & returns....   Hi Friend, Try the following code: import javax.swing.*; class
Java code
Java code   Create an Employee class which has methods netSalary which would accept salary & tax as arguments & returns the netSalary which... the following code: import java.util.*; class Employee { static Scanner input=new
java code
java code  An employee _id consist of 5 digits is stored in a string variable strEmpid. Now Mr.Deb wants to store this Id in Integer type to IntEmpid. write Java statements to do
java code
java code  input any word ie risk,resul is-- r ri ris risk
java code
java code  Create a calculator class which will have methods add, multiply, divide & subtract
Tutorials