Java Code Examples for com.ibm.icu.util.ULocale#forLocale()
The following examples show how to use
com.ibm.icu.util.ULocale#forLocale() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateFormatterTest.java From birt with Eclipse Public License 1.0 | 6 votes |
@Test public void testDateFormatLocale( ) { Locale locale = new Locale( "en", "us" ); DateFormatter sample = new DateFormatter( ULocale.forLocale(locale) ); Locale locDef = Locale.getDefault( ); Calendar dateCal = Calendar.getInstance( locDef ); dateCal.set( 1998, 8, 13, 20, 1, 44 ); Date date = dateCal.getTime( ); //assertEquals(sampleJava.format(date), sample.format(date)); locale = Locale.ITALY; sample = new DateFormatter( ULocale.forLocale(locale) ); SimpleDateFormat sampleJava = new SimpleDateFormat( "MM/dd/yy KK:mm aa", locale ); //assertEquals(sampleJava.format(date), sample.format(date)); sample.applyPattern( "MM/dd/yy KK:mm aa" ); assertEquals( "09/13/98 08:01 PM", sample.format( date ) ); sample = new DateFormatter( "Long Date", ULocale.forLocale(locale) ); assertEquals( "13 settembre 1998", sample.format( date ) ); assertTrue( true ); }
Example 2
Source File: ExecutionContext.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Set the cancel flag. */ public void cancel( ) { isCancelled = true; // cancel the dte's session if ( dataEngine != null ) { DataRequestSession session = dataEngine.getDTESession( ); if ( session != null ) { session.cancel( ); } } if ( task != null ) { IStatusHandler handle = task.getStatusHandler( ); if ( handle != null ) { EngineResourceHandle rc = new EngineResourceHandle( ULocale.forLocale( getLocale( ) ) ); handle.showStatus( rc.getMessage( MessageConstants.TASK_CANCEL ) ); } } }
Example 3
Source File: DateFormatterTest.java From birt with Eclipse Public License 1.0 | 5 votes |
@Test public void testDateFormatStringLocale( ) { Locale locale = new Locale( "en", "us" ); DateFormatter sample = new DateFormatter( "MM/dd/yyyy hh:mm:ss a", ULocale.forLocale(locale) ); Locale locDef = Locale.getDefault( ); Calendar dateCal = Calendar.getInstance( locDef ); dateCal.set( 1998, 8, 13, 20, 1, 44 ); Date date = dateCal.getTime( ); assertEquals( "09/13/1998 08:01:44 PM", sample.format( date ) ); }
Example 4
Source File: DataEngineContext.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * @param locale * The current task's locale */ public void setLocale( Locale locale ) { currentLocale = ULocale.forLocale( locale ); DataException.setLocale( currentLocale ); }
Example 5
Source File: DateFormatterTest.java From birt with Eclipse Public License 1.0 | 5 votes |
@Test public void testGetPattern( ) { Locale locale = new Locale( "en", "us" ); DateFormatter sample = new DateFormatter( "MM/dd/yyyy hh:mm:ss a", ULocale.forLocale(locale) ); assertEquals( "MM/dd/yyyy hh:mm:ss a", sample.getPattern( ) ); }
Example 6
Source File: ModuleOption.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Gets the locale. * * @return the locale */ public ULocale getLocale( ) { Object locale = options.get( LOCALE_KEY ); if ( locale instanceof ULocale ) return (ULocale) locale; else if ( locale instanceof Locale ) { return ULocale.forLocale( ( (Locale) locale ) ); } return null; }
Example 7
Source File: ExcelContext.java From birt with Eclipse Public License 1.0 | 5 votes |
public void initialize( IEmitterServices service ) throws EngineException { if ( service == null ) { return; } out = EmitterUtil.getOuputStream( service, "report.xls" ); if ( service.getReportEngine( ) != null ) { this.tempFileDir = service.getReportEngine( ).getConfig( ) .getTempDir( ); } IReportContext reportContext = service.getReportContext( ); if ( reportContext != null ) { Locale locale = reportContext.getLocale( ); this.locale = locale == null ? ULocale.getDefault( ) : ULocale .forLocale( locale ); this.timeZone = reportContext.getTimeZone( ); if ( timeZone == null ) { timeZone = TimeZone.getDefault( ); } } IRenderOption renderOption = service.getRenderOption( ); Object option = renderOption .getOption( IExcelRenderOption.OPTION_MULTIPLE_SHEET ); if ( option instanceof Boolean ) enableMultipleSheet = (Boolean) option; this.reportContext = service.getReportContext( ); }
Example 8
Source File: PDFPageDevice.java From birt with Eclipse Public License 1.0 | 4 votes |
public void createTOC( Set<String> bookmarks ) { // we needn't create the TOC if there is no page in the PDF file. // the doc is opened only if the user invokes newPage. if ( !doc.isOpen( ) ) { return; } if ( bookmarks.isEmpty( ) ) { writer.setViewerPreferences( PdfWriter.PageModeUseNone ); return; } ULocale ulocale = null; Locale locale = context.getLocale( ); if ( locale == null ) { ulocale = ULocale.getDefault( ); } else { ulocale = ULocale.forLocale( locale ); } // Before closing the document, we need to create TOC. ITOCTree tocTree = report.getTOCTree( "pdf", //$NON-NLS-1$ ulocale ); if ( tocTree == null ) { writer.setViewerPreferences( PdfWriter.PageModeUseNone ); } else { TOCNode rootNode = tocTree.getRoot( ); if ( rootNode == null || rootNode.getChildren( ).isEmpty( ) ) { writer.setViewerPreferences( PdfWriter.PageModeUseNone ); } else { writer.setViewerPreferences( PdfWriter.PageModeUseOutlines ); TOCHandler tocHandler = new TOCHandler( rootNode, writer .getDirectContent( ).getRootOutline( ), bookmarks ); tocHandler.createTOC( ); } } }
Example 9
Source File: CommonDataExtractionImpl.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Initializes the common options based on the data extraction option. If * the passed option doesn't contain common options, use default values. * * @param context * @param options * options */ private void initCommonOptions( IReportContext context, IDataExtractionOption options ) { String dateFormat = null; ICommonDataExtractionOption commonOptions; if ( options instanceof ICommonDataExtractionOption ) { commonOptions = (ICommonDataExtractionOption) options; } else { commonOptions = new CommonDataExtractionOption( options.getOptions( ) ); } this.isLocaleNeutral = commonOptions.isLocaleNeutralFormat( ); this.localeNeutralFlags = commonOptions.getLocaleNeutralFlags( ); dateFormat = commonOptions.getDateFormat( ); // get locale info Locale aLocale = null; if ( commonOptions.getLocale( ) != null ) { aLocale = commonOptions.getLocale( ); } else if ( context != null ) { aLocale = context.getLocale( ); } if ( aLocale == null ) { this.locale = ULocale.forLocale( Locale.getDefault( ) ); } else { this.locale = ULocale.forLocale( aLocale ); } java.util.TimeZone javaTimeZone = commonOptions.getTimeZone( ); if ( javaTimeZone != null ) { // convert java time zone to ICU time zone this.timeZone = TimeZone.getTimeZone( javaTimeZone.getID( ) ); } else if ( context != null ) { timeZone = context.getTimeZone( ); } else { timeZone = TimeZone.getDefault( ); } if ( !isLocaleNeutral ) { dateFormatter = createDateFormatter( dateFormat, this.locale, this.timeZone ); } formatterMap = commonOptions.getFormatter( ); }
Example 10
Source File: DateFormatter.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @deprecated since 2.1 * @return */ public DateFormatter( String pattern, Locale localeLoc ) { this( pattern, ULocale.forLocale( localeLoc ) ); }
Example 11
Source File: NumberFormatter.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @deprecated since 2.1 * @return */ public NumberFormatter( String pattern, Locale locale ) { this( pattern, ULocale.forLocale( locale ) ); }
Example 12
Source File: StringFormatter.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @deprecated since 2.1 * @return */ public StringFormatter( Locale locale ) { this(ULocale.forLocale(locale)); }
Example 13
Source File: StringFormatter.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @deprecated since 2.1 * @return */ public StringFormatter( String format, Locale locale) { this(format, ULocale.forLocale(locale)); }
Example 14
Source File: ResourceHandle.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @deprecated since 2.1 * @return */ public ResourceHandle( Locale locale ) { this(ULocale.forLocale(locale)); }
Example 15
Source File: SessionHandleImpl.java From birt with Eclipse Public License 1.0 | 3 votes |
/** * Constructs a handle for the session with the given locale. * * @param locale * the user's locale. If null, then the system locale is assumed. * * @deprecated to use ICU4J, this method is replaced by: * SessionHandle(ULocale locale) */ public SessionHandleImpl( Locale locale ) { ULocale uLocale = ULocale.forLocale( locale ); session = new DesignSession( uLocale ); }
Example 16
Source File: DateFormatSymbols.java From fitnotifications with Apache License 2.0 | 2 votes |
/** * Variant of DateFormatSymbols(Calendar, Locale) that takes the Calendar class * instead of a Calendar instance. * @see #DateFormatSymbols(Calendar, Locale) * @stable ICU 2.2 */ public DateFormatSymbols(Class<? extends Calendar> calendarClass, Locale locale) { this(calendarClass, ULocale.forLocale(locale)); }
Example 17
Source File: DateFormatSymbols.java From fitnotifications with Apache License 2.0 | 2 votes |
/** * Constructs a DateFormatSymbols object by loading format data from * resources for the given locale. * * @throws java.util.MissingResourceException if the resources for the specified * locale cannot be found or cannot be loaded. * @stable ICU 2.0 */ public DateFormatSymbols(Locale locale) { this(ULocale.forLocale(locale)); }
Example 18
Source File: RuleBasedNumberFormat.java From fitnotifications with Apache License 2.0 | 2 votes |
/** * Creates a RuleBasedNumberFormat from a predefined description. The selector * code chooses among three possible predefined formats: spellout, ordinal, * and duration. * @param locale The locale for the formatter. * @param format A selector code specifying which kind of formatter to create for that * locale. There are three legal values: SPELLOUT, which creates a formatter that * spells out a value in words in the desired language, ORDINAL, which attaches * an ordinal suffix from the desired language to the end of a number (e.g. "123rd"), * and DURATION, which formats a duration in seconds as hours, minutes, and seconds. * @stable ICU 2.0 */ public RuleBasedNumberFormat(Locale locale, int format) { this(ULocale.forLocale(locale), format); }
Example 19
Source File: RuleBasedNumberFormat.java From fitnotifications with Apache License 2.0 | 2 votes |
/** * Creates a RuleBasedNumberFormat that behaves according to the description * passed in. The formatter uses the specified locale to determine the * characters to use when formatting in numerals, and to define equivalences * for lenient parsing. * @param description A description of the formatter's desired behavior. * See the class documentation for a complete explanation of the description * syntax. * @param locale A locale, which governs which characters are used for * formatting values in numerals, and which characters are equivalent in * lenient parsing. * @stable ICU 2.0 */ public RuleBasedNumberFormat(String description, Locale locale) { this(description, ULocale.forLocale(locale)); }
Example 20
Source File: AlphabeticIndex.java From fitnotifications with Apache License 2.0 | 2 votes |
/** * Create the index object. * * @param locale * The locale for the index. * @stable ICU 4.8 */ public AlphabeticIndex(Locale locale) { this(ULocale.forLocale(locale), null); }