共用方式為


SPRegionalSettings class

表示執行 wssnoverslongMicrosoft SharePoint Foundation 的伺服器上使用的區域設定。

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.SPRegionalSettings

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public Class SPRegionalSettings
'用途
Dim instance As SPRegionalSettings
public class SPRegionalSettings

備註

使用SPWeb類別之RegionalSettings屬性可傳回SPRegionalSettings物件,代表網站的地區設定。您可以傳回SPRegionalSettings建構函式透過相同的地區設定。使用SPUser類別之RegionalSettings屬性可傳回SPRegionalSettings物件,代表使用者的地區設定。

如果您修改的地區設定的網站透過Locale屬性並呼叫Update方法,以套用變更,在現有的網站物件上的下列屬性會反映原始地區設定,而不是新的 api。若要擷取新的設定,請建立新網站物件,您可以使用**OpenWeb()**方法,來存取地區設定 (例如, newWebSiteObject.RegionalSettings.DateFormat) 的內容執行動作。

AM

PM

DateFormat

DateSeparator

DecimalSeparator

DigitGrouping

NegativeSign

NegNumberMode

PositiveSign

ThousandSeparator

TimeMarkerPosition

TimeSeparator

Examples

下列程式碼範例會建立網站集合內的子網站、 修改日期格式的地區設定中用於新的網站],然後顯示新的設定。

Dim siteCollection As New SPSite("https://localhost")
Try
    Dim rootWebSite As SPWeb = siteCollection.RootWeb
    Dim newSubSite As SPWeb = rootWebSite.Webs.Add("MySite")
    newSubSite.Locale = CultureInfo.CreateSpecificCulture("ja-JP")

    newSubSite.Update()

    Dim webSite As SPWeb = siteCollection.OpenWeb(rootWebSite.Webs("MySite").ID)
    Response.Write(webSite.RegionalSettings.DateFormat)

    rootWebSite.Dispose()
    newSubSite.Dispose()
    webSite.Dispose()
Finally
    siteCollection.Dispose()
End Try
using (SPSite oSiteCollection = new SPSite("https://localhost"))
{
    SPWeb oWebsiteRoot = oSiteCollection.RootWeb;
    SPWeb oWebsiteNew = oWebsiteRoot.Webs.Add("MySite");
    oWebsiteNew.Locale = CultureInfo.CreateSpecificCulture("ja-JP");

    oWebsiteNew.Update();

    SPWeb oWebsiteCurrent = oSiteCollection.OpenWeb(oWebsiteRoot.Webs["MySite"].ID);
    Response.Write(oWebsiteCurrent.RegionalSettings.DateFormat);
    oWebsiteRoot.Dispose();
    oWebsiteNew.Dispose();
    oWebsiteCurrent.Dispose();
}
注意事項注意事項

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

請參閱

參照

SPRegionalSettings members

Microsoft.SharePoint namespace