第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

用calendar怎么寫出日歷

怎樣顯示當(dāng)前日歷

正在回答

4 回答

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Arrays;

import java.util.Calendar;

import java.util.Date;

import java.util.Scanner;


public class Wor3 {

/*.分析以下需求,并用代碼實(shí)現(xiàn):

(1)通過(guò)鍵盤錄入日期字符串,格式(2015-10-20)

(2)輸出該日期是星期幾及這一年的第幾天

(3)如輸入:2015-10-20,輸出"2015年-10月-20日 是 星期二,是 ?2015年的第 293 天"

*/

public static void main(String[] args) throws ParseException {

Scanner sc = new Scanner(System.in);

System.out.println("請(qǐng)輸入日期,如輸入:2015-10-20");

String lineday=sc.nextLine();

//demo1(lineday);

//demo2(lineday);

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");?

Date d = sdf.parse(lineday);

SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy年MM月dd日,是E,是y中的第D天");

System.out.println(sdf1.format(d));

}


private static void demo2(String lineday) {

String []sarr=lineday.split("-");

int []arr=new int[sarr.length];

for(int i=0;i<sarr.length;i++){

arr[i]=Integer.valueOf(sarr[i]);

}

//System.out.println(Arrays.toString(arr));

Calendar c =Calendar.getInstance();

c.set(arr[0],( arr[1]-1), arr[2]);

System.out.println(c.get(Calendar.YEAR)+"年-"+(c.get(Calendar.MONTH)+1)+"月-"

+c.get(Calendar.DATE)+"日是"+getWeek(c.get(Calendar.DAY_OF_WEEK))+"是"

+c.get(Calendar.YEAR)+"年的第"+c.get(Calendar.DAY_OF_YEAR)+"天");

}


private static String getWeek(int week) {

String arr[]={"","星期日","星期一","星期二","星期三","星期四","星期五","星期六"};

return arr[week];

}


private static void demo1(String lineday) throws ParseException {

SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");

Date d = sdf.parse(lineday);

System.out.println(d);

SimpleDateFormat sdf1= new SimpleDateFormat("yyyy年-MM月-dd日 " +

" 是E,是y年的第D天");

System.out.println(sdf1.format(d));

}

}


0 回復(fù) 有任何疑惑可以回復(fù)我~

精簡(jiǎn)版?

package com.imooc;

import java.time.*;

public class CalendarTest?

{

public static void main(String[] args)

? {

? ? LocalDate date=LocalDate.now();

? ? int month=date.getMonthValue();

? ? int today=date.getDayOfMonth();


? ? date=date.minusDays(today-1);

? ? DayOfWeek weekday=date.getDayOfWeek();

? ? int value=weekday.getValue();


? ? System.out.println("Mon Tue Wed Thu Fri Sat Sun");

? ? for(int i = 1; i < value;i++)

? ? ? System.out.print(" ? ?");

while (date.getMonthValue()==month)

{

?System.out.printf("%3d",date.getDayOfMonth());

?if (date.getDayOfMonth()==today)

? ? ?System.out.print("*");

?else

?System.out.print(" ");

?date=date.plusDays(1);

?if (date.getDayOfWeek().getValue()==1)System.out.println();

}

if(date.getDayOfWeek().getValue()!=1)System.out.println();

? }

}


1 回復(fù) 有任何疑惑可以回復(fù)我~

輸入密碼查看答案

0 回復(fù) 有任何疑惑可以回復(fù)我~

首先你得能看明白這個(gè)

1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

用calendar怎么寫出日歷

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)