Microsoft AJAX Library Cheat Sheet(2): Boolean和Date類型的擴充

來源:互聯網
上載者:User

 

本文為翻譯,英文原版的Cheat Sheet(PDF版本)在此下載:http://aspnetresources.com/downloads/ms_ajax_library_cheat_sheets1.zip

原作著作權聲明:

Copyright (c) 2004-2006, Milan Negovanhttp://www.AspNetResources.comAll rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditionsare met:* Redistributions of source code must retain the above copyrightnotice, this list of conditions and the following disclaimer.* Redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclaimer inthe documentation and/or other materials provided with thedistribution.* The name of the author may not be used to endorse or promote productsderived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITEDTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OROTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IFADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 

註:標註有[S]的為靜態方法,無須執行個體化對象即可使用。

 

[S] Boolean.parse (value )

從字串表示的布爾值解析成相應的Boolean類型。value參數必須為“true”或“false”二者之一,不區分大小寫,且可以包含空格。

var b = Boolean.parse("true");

 

Date.format (format)

格式化字串(地區設定無關)。

var d = new Date();
Sys.Debug.trace (d.format("dddd, dd MMMM yyyy HH:mm:ss"));

 

Date.localeFormat (format)

格式化字串(地區設定相關)。使用Sys.CultureInfo.CurrentCulture得到地區屬性。

var d = new Date();
Sys.Debug.trace (d.localeFormat("dddd, dd MMMM yyyy HH:mm:ss"));

 

[S] Date.parseLocale (value, formats)

從字串表示的本地時間日期解析成相應的Date類型。使用Sys.CultureInfo.CurrentCulture得到地區屬性。

Sys.Debug.trace (Date.parseLocale ("4/10/2001", "yyyy-MM-dd",
"MM/dd/yyyy"));
// Date.parseLocale will skip the first format here as invalid and use
// the second one. If it does not find an appropriate format,
// the function throws an exception.

 

[S] Date.parseInvariant (value, formats)

從字串表示的地區無關時間日期解析成相應的Date類型。

Sys.Debug.trace (Date.parseInvariant ("4/10/2001", "yyyy-MM-dd",
"MM/dd/yyyy"));
// Date.parseInvariant will skip the first format here as invalid and use
// the second one. If it does not find an appropriate format,
// the function throws an exception.

 

支援的格式

 

  1. d: 縮寫日期(e.g.: 02/17/2007):
  2. D: 完整日期(e.g: Saturday, 17 February 2007)
  3. t: 縮寫時間(e.g.: 22:10)
  4. T: 完整時間(e.g.: 22:10:30)
  5. F: 完整時間日期(e.g.: Saturday, 17 February 2007 22:10:30)
  6. m (or M): 月和日(e.g.: February 17)
  7. s: 可排序的時間日期(e.g.: 2007-02-17T22:10:30)
  8. y (or Y): 年和月(e.g.: 2007 February)
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.