import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class TestBook { public static void main(String[] args){ Date date=new Date(); Calendar ca=Calendar.getInstance(); ca.setTime(date); SimpleDateFormat format=new SimpleDateFormat("yyyy年MM月dd日"); String dateString=format.format(date); int dayOfYear=ca.get(Calendar.DAY_OF_YEAR); int dayOfMonth=ca.get(Calendar.DAY_OF_MONTH); int weekOfYear=ca.get(Calendar.WEEK_OF_YEAR); System.out.println("当前时间是"+dateString+"--今年的第"+dayOfYear+"天--本月的第"+dayOfMonth+"天"); System.out.println("今年的第"+weekOfYear+"周"); } }