SPRegionalSettings class
Represents regional settings that are used on the server that is running Microsoft SharePoint Foundation.
Inheritance hierarchy
System.Object
Microsoft.SharePoint.SPRegionalSettings
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Class SPRegionalSettings
'Usage
Dim instance As SPRegionalSettings
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).
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("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();
}
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 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.