集册 Java实例教程 使用日历显示星期几

使用日历显示星期几

欢马劈雪     最近更新时间:2020-01-02 10:19:05

631
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用日历显示星期几


import java.util.Calendar;/*nowjava.com 提 供*/

 

public class Main {

 

  public static void main(String[] args) {

 

    //create Calendar instance

    Calendar now = Calendar.getInstance();

   

    System.out.println("Current date : " + (now.get(Calendar.MONTH) + 1)

                        + "-"

                        + now.get(Calendar.DATE)

                        + "-"

                        + now.get(Calendar.YEAR));

   

    //create an array of days

    String[] strDays = new String[]{

                      "Sunday",

                      "Monday",
                      /*
                      时代Java - nowjava.com
                      */

                      "Tuesday",

                      "Wednesday",

                      "Thusday",

                      "Friday",

                      "Saturday"

                    };

   

    
展开阅读全文