SPRegionalSettings class

Represents regional settings that are used on the server that is running Microsoft SharePoint Foundation.


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

public class SPRegionalSettings

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).

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.

using (SPSite oSiteCollection = new SPSite("http://localhost"))
    SPWeb oWebsiteRoot = oSiteCollection.RootWeb;
    SPWeb oWebsiteNew = oWebsiteRoot.Webs.Add("MySite");
    oWebsiteNew.Locale = CultureInfo.CreateSpecificCulture("ja-JP");


    SPWeb oWebsiteCurrent = oSiteCollection.OpenWeb(oWebsiteRoot.Webs["MySite"].ID);

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.

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