下面是一个显示时间的简单的java
希望对你有些帮助
具体的显示农历我也不是很清楚
package Gog;
import java.util.Calendar;
public class Text03 {
public static void main (String[]args){
Calendar now = Calendar.getInstance();
int hour =now.get(Calendar.HOUR_OF_DAY);
int minute =now.get(Calendar.MINUTE);
int mouth =now.get(Calendar.MONTH)+1;
int day =now.get(Calendar.DAY_OF_MONTH);
int year =now.get(Calendar.YEAR);
if (hour<12){
System.out.println("Good morning.\n");
}else if (hour<17){
System.out.println("Good afternoon.\n");
}else {
System.out.println("Good evening.\n");
}
System.out.print("It's");
if (minute !=0){
System.out.println(" "+minute+" ");
System.out.println((minute!=1)? "minute":"minute");
System.out.println("past");
}
System.out.println(" ");
System.out.println((hour<12)?(hour-12):hour);
System.out.println("o'clock on");
switch(mouth){
case 1:
System.out.println("January");
break;
case 2:
System.out.println("February");
break;
case 3:
System.out.println("March");
break;
case 4:
System.out.println("April");
break;
case 5:
System.out.println("May");
break;
case 6:
System.out.println("June");
break;
case 7:
System.out.println("July");
break;
case 8:
System.out.println("August");
break;
case 9:
System.out.println("September");
break;
case 10:
System.out.println("October");
break;
case 11:
System.out.println("November");
break;
case 12:
System.out.println("December");
break;
}
System.out.println(" "+day+","+year+".");
}
}