Поделиться через


SPRegionalSettings Class

Represents regional settings that are used on the server that is running Windows SharePoint Services.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.SPRegionalSettings

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

Syntax

<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPRegionalSettings

Dim instance As SPRegionalSettings
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPRegionalSettings

Remarks

Use the RegionalSettings property of the SPWeb class to return an SPRegionalSettings object that represents the regional settings for a Web site. You can return the same regional settings through the SPRegionalSettings constructor. Use the RegionalSettings property of the SPUser class to return an SPRegionalSettings object that represents the regional settings for a user.

If you modify the locale of a Web site through the Locale property and call the Update method to apply changes, the following properties on the existing Web site object reflect the original regional settings, not the new ones. To retrieve the new settings, create a new Web site object, which you can do by using the OpenWeb() method, to access the properties for regional settings (for example, newWebSiteObject.RegionalSettings.DateFormat).

AM

PM

DateFormat

DateSeparator

DecimalSeparator

DigitGrouping

NegativeSign

NegNumberMode

PositiveSign

ThousandSeparator

TimeMarkerPosition

TimeSeparator

Examples

The following code example creates a subsite within a site collection, modifies the date format that is used in regional settings for the new Web site, and then displays the new setting.

Dim siteCollection As New SPSite("http://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("http://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();
}

Note

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 Best Practices: Using Disposable Windows SharePoint Services 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.

See Also

Reference

SPRegionalSettings Members

Microsoft.SharePoint Namespace