Eric J. Bowersox 2e455b4bdd implemented front page content management, finally wired up the user locale
and timezone default mechanism, and did some other bugfixing and stuff
2001-02-28 07:55:00 +00:00

63 lines
2.1 KiB
Java

/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.util;
import java.util.*;
public class LocaleFactory
{
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
private LocaleFactory()
{ // this object cannot be instantiated
} // end constructor
/*--------------------------------------------------------------------------------
* External static operations
*--------------------------------------------------------------------------------
*/
public static Locale createLocale(String streq)
{
if ((streq==null) || (streq.length()==0))
return Locale.getDefault();
int p1 = streq.indexOf('_');
if (p1<0)
return new Locale(streq,"");
String x_lang = streq.substring(0,p1);
int p2 = streq.indexOf('_',p1+1);
if (p2<0)
{ // there's only one underscore - figure out what part the last part is
String lastpart = streq.substring(p1+1);
if (lastpart.length()==2)
return new Locale(streq.substring(0,p1),lastpart);
else
return new Locale(streq.substring(0,p1),"",lastpart);
} // end if
// do all three variants
return new Locale(streq.substring(0,p1),streq.substring(p1+1,p2),streq.substring(p2+1));
} // end createLocale
} // end class LocaleFactory