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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

未來的日歷 DatePicker

未來的日歷 DatePicker

紫衣仙女 2023-05-10 17:23:07
我希望能夠使 javascript 自動(dòng)選擇從今天開始的 2 天,不知道如何執(zhí)行它?!癡alueFrom”當(dāng)前正在自動(dòng)選擇 LocalDate。要更改的代碼:“ValueTo”public CorporateMessagesPage selectDateAndPlaceOrder() {    String valueFrom = "arguments[0].value = '" + DateTime.now().toString("dd/MM/yyyy") + "'";    String valueTo = (valueFrom +2);    JavascriptExecutor javascriptExecutor = (JavascriptExecutor) webDriver;    System.out.print(String.valueOf(LocalDate.now()));    javascriptExecutor.executeScript(valueFrom, validFromDate);    javascriptExecutor.executeScript(valueTo, validToDate);    return PageFactory.initElements(webDriver, CorporateMessagesPage.class);}我希望“ValueTo”等于“ValueFrom”+ 2 天。塊引用
查看完整描述

2 回答

?
海綿寶寶撒

TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個(gè)贊

您可以使用其行業(yè)領(lǐng)先的java.time類在 Java 中完成所有這些工作。不需要 JavaScript。


LocalDate? ? ? ? ? ? ? ? ? ? ? ? ? // Represent a date-only value, without time-of-day and without time zone or offset-from-UTC.

.now()? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// Capture the date as seen in the wall-clock time in the JVM’s current default time zone. Better to specify the desired/expected time zone explicitly.

.plusDays( 2 )? ? ? ? ? ? ? ? ? ? ?// Date math, adding days to move forward in time.

.format(? ? ? ? ? ? ? ? ? ? ? ? ? ?// Generate text to represent the value of this date.

? ? DateTimeFormatter? ? ? ? ? ? ? // Specify format.

? ? .ofLocalizedDate(? ? ? ? ? ? ? // Automatically localize according to the human language and cultural norms of a specific `Locale`.?

? ? ? ? FormatStyle.SHORT? ? ? ? ? // How long or abbreviated to present this value.

? ? )? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // Returns a `DateTimeFormatter` object.

? ? .withLocale( Locale.UK )? ? ? ?// Returns another `DateTimeFormatter` object, per Immutable Objects pattern.

)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // Returns a `String`.?

03/08/2019

java.time

LocalDate

該類LocalDate表示沒有日期時(shí)間和時(shí)區(qū)或offset-from-UTC 的僅日期值。

時(shí)區(qū)對(duì)于確定日期至關(guān)重要。對(duì)于任何給定時(shí)刻,日期在全球范圍內(nèi)因地區(qū)而異。例如,在法國巴黎午夜過后幾分鐘是新的一天,而在魁北克蒙特利爾仍然是“昨天” 。

如果未指定時(shí)區(qū),則 JVM 隱式應(yīng)用其當(dāng)前默認(rèn)時(shí)區(qū)。該默認(rèn)值可能會(huì)在運(yùn)行時(shí)隨時(shí)更改(!),因此您的結(jié)果可能會(huì)有所不同。最好明確指定您想要/預(yù)期的時(shí)區(qū)作為參數(shù)。如果關(guān)鍵,請(qǐng)與您的用戶確認(rèn)該區(qū)域。

以、或 等格式指定適當(dāng)?shù)臅r(shí)區(qū)名稱。切勿使用 2-4 字母縮寫,例如或因?yàn)樗鼈?em>不是真正的時(shí)區(qū)、未標(biāo)準(zhǔn)化,甚至不是唯一的(?。?。Continent/RegionAmerica/MontrealAfrica/CasablancaPacific/AucklandESTIST

ZoneId?z?=?ZoneId.of(?"America/Montreal"?)?;??
LocalDate?today?=?LocalDate.now(?z?)?;

如果你想使用 JVM 的當(dāng)前默認(rèn)時(shí)區(qū),請(qǐng)求它并作為參數(shù)傳遞。如果省略,代碼將變得難以閱讀,因?yàn)槲覀儾淮_定您是否打算使用默認(rèn)值,或者您是否像許多程序員一樣沒有意識(shí)到這個(gè)問題。

ZoneId?z?=?ZoneId.systemDefault()?;??//?Get?JVM’s?current?default?time?zone.

日期數(shù)學(xué)

使用上找到的plus…&方法及時(shí)向前或向后移動(dòng)。minus…LocalDate

LocalDate?dayAfterNext?=?LocalDate.now(?z?).plusDays(?2?)?;

或者使用Period類。

Period?twoDays?=?Period.ofDays(?2?)?;
LocalDate?later?=?LocalDate.now(?z?).plus(?twoDays?)?;

生成文本

用于DateTimeFormatter生成表示對(duì)象值的文本LocalDate。您可以自動(dòng)本地化或指定自定義格式模式。

查看完整回答
反對(duì) 回復(fù) 2023-05-10
?
斯蒂芬大帝

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊

您可以使用 java calendar 來獲得您想要的時(shí)間


        SimpleDateFormat obj_dateFormat = new SimpleDateFormat("dd/MM/yyyy");

        Calendar calender = Calendar.getInstance();


        //get valueFrom

        String valueFrom = obj_dateFormat.format(new Date(calender.getTimeInMillis()));


         //Add 2 days in current time

        calender.add(Calendar.DAY_OF_MONTH, 2);


        //get valueTo

        String valueTo = obj_dateFormat.format(new Date(calender.getTimeInMillis()));



查看完整回答
反對(duì) 回復(fù) 2023-05-10
  • 2 回答
  • 0 關(guān)注
  • 122 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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