回复 2楼 日知己所无
你能帮我看看这个
public class Testsum {
public static void main(String[] args){
long totalMilliseconds = System.currentTimeMillis();
long totalSeconds = totalMilliseconds/1000;
long currentSeconds = totalSeconds % 60;
long totalMinutes = totalSeconds / 60;
long currentMinutes = totalMinutes % 60;
long totalHours = totalMinutes / 60;
long currentHours = totalHours % 24;
long totalDay = totalHours / 24;
long totalYears = totalDay/365;
int currentYears = (int)(totalYears +1970);
int days = (int)(totalDay%365);
if((currentYears%4==0 && currentYears%100!=0 )|| currentYears%400==0){
if(days<=30){
int days2=days+1;
System.out.println("Current date and time is Junuary"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=59){
int days2=days-30;
System.out.println("Current date and time is February"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=90){
int days2=days-59;
System.out.println("Current date and time is March"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=120){
int days2=days-90;
System.out.println("Current date and time is May"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=151){
int days2=days-120;
System.out.println("Current date and time is April"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=181){
int days2=days-151;
System.out.println("Current date and time is June"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=212){
int days2=days-181;
System.out.println("Current date and time is July"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=243){
int days2=days-212;
System.out.println("Current date and time is August"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=272){
int days2=days-242;
System.out.println("Current date and time is Sept"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=303){
int days2=days-272;
System.out.println("Current date and time is October"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=333){
int days2=days-303;
System.out.println("Current date and time is November"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=353){
int days2=days-333;
System.out.println("Current date and time is November"+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
}
else{
if(days<=30){
int days2=days+1;
System.out.println("Current date and time is Junuary "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=58){
int days2=days-30;
System.out.println("Current date and time is February "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=89){
int days2=days-58;
System.out.println("Current date and time is March "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=119){
int days2=days-89;
System.out.println("Current date and time is May "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=150){
int days2=days-119;
System.out.println("Current date and time is April "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=180){
int days2=days-150;
System.out.println("Current date and time is June "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=211){
int days2=days-180;
System.out.println("Current date and time is July "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=242){
int days2=days-211;
System.out.println("Current date and time is August "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=271){
int days2=days-241;
System.out.println("Current date and time is Sept "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=302){
int days2=days-271;
System.out.println("Current date and time is October "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=332){
int days2=days-302;
System.out.println("Current date and time is November "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
else if(days<=352){
int days2=days-332;
System.out.println("Current date and time is November "+days2+", "+currentYears+" "+currentHours+":"+currentMinutes+":"+currentSeconds);
}
}
}
}