• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LocaleUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.poi.util.LocaleUtil的典型用法代码示例。如果您正苦于以下问题:Java LocaleUtil类的具体用法?Java LocaleUtil怎么用?Java LocaleUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LocaleUtil类属于org.apache.poi.util包,在下文中一共展示了LocaleUtil类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getJavaCalendar

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
/**
 * Get EXCEL date as Java Calendar with given time zone.
 * @param date  The Excel date.
 * @param use1904windowing  true if date uses 1904 windowing,
 *  or false if using 1900 date windowing.
 * @param timeZone The TimeZone to evaluate the date in
 * @param roundSeconds round to closest second
 * @return Java representation of the date, or null if date is not a valid Excel date
 */
public static Calendar getJavaCalendar(double date, boolean use1904windowing, TimeZone timeZone, boolean roundSeconds) {
    if (!isValidExcelDate(date)) {
        return null;
    }
    int wholeDays = (int)Math.floor(date);
    int millisecondsInDay = (int)((date - wholeDays) * DAY_MILLISECONDS + 0.5);
    Calendar calendar;
    if (timeZone != null) {
        calendar = LocaleUtil.getLocaleCalendar(timeZone);
    } else {
        calendar = LocaleUtil.getLocaleCalendar(); // using default time-zone
    }
    setCalendar(calendar, wholeDays, millisecondsInDay, use1904windowing, roundSeconds);
    return calendar;
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:25,代码来源:ExcelDateUtil.java


示例2: getData

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
private ByteArrayEditableData getData() throws IOException, TreeModelLoadException {
	if (packagePart instanceof PackagePropertiesPart) {
		return new ByteArrayEditableData("Property parts can't be exported.".getBytes(LocaleUtil.CHARSET_1252));
	}
	
	FileMagic fm;
	try (InputStream is = FileMagic.prepareToCheckMagic(packagePart.getInputStream())) {
		final ByteArrayEditableData data = new ByteArrayEditableData();
		fm = FileMagic.valueOf(is);
		if (fm == FileMagic.OLE2) {
			if (oleFile == null) {
				oleFile = copyToTempFile(is);
				OLETreeModel poifsNode = appContext.getBean(OLETreeModel.class, treeNode);
				poifsNode.load(oleFile);
				((TreeModelEntry)treeNode.getUserObject()).activate();
			}
			
			try (InputStream is2 = new FileInputStream(oleFile)) {
				data.loadFromStream(is2);
			}
		} else {
			data.loadFromStream(is);
		}
		return data;
	}
	
}
 
开发者ID:kiwiwings,项目名称:poi-visualizer,代码行数:28,代码来源:OPCEntry.java


示例3: parseYYYYMMDDDateInternal

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
private static Date parseYYYYMMDDDateInternal(String timeStr) throws FormatException {
    if(timeStr.length() != 10) {
        throw new FormatException("Bad length");
    }

    String yearStr = timeStr.substring(0, 4);
    String monthStr = timeStr.substring(5, 7);
    String dayStr = timeStr.substring(8, 10);
    int year = parseInt(yearStr, "year", Short.MIN_VALUE, Short.MAX_VALUE);
    int month = parseInt(monthStr, "month", 1, 12);
    int day = parseInt(dayStr, "day", 1, 31);

    Calendar cal = LocaleUtil.getLocaleCalendar(year, month-1, day);
    return cal.getTime();
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:16,代码来源:ExcelDateUtil.java


示例4: generateSheetData

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
private static void generateSheetData(final Sheet sheet, final CellStyle style, short startingRow) {
  int currentRow = startingRow;
  // Create first row values
  Row row1 = sheet.createRow(currentRow++);
  row1.createCell(0).setCellValue(1.0);
  row1.createCell(1).setCellValue("One");
  row1.createCell(2).setCellValue("One");
  Cell c13 = row1.createCell(3);
  c13.setCellValue(LocaleUtil.getLocaleCalendar(1983, 04/*zero based*/, 18, 4, 0, 0));
  c13.setCellStyle(style);
  Cell c14 = row1.createCell(4);
  c14.setCellFormula("A2+1");
  // For formulas we read pre-computed values. Editors set the precomputed value by default. We need to add it here
  // explicitly as the library doesn't pre compute the formula value.
  c14.setCellValue(2.0d);
  row1.createCell(5).setCellValue(true);
  row1.createCell(6).setCellFormula("B2*20");
  row1.createCell(6).setCellValue("#ERROR");

  // Create second row values
  Row row2 = sheet.createRow(currentRow++);
  row2.createCell(0).setCellValue(2.0);
  row2.createCell(1).setCellValue("Two");
  row2.createCell(2).setCellValue("Two");
  Cell c23 = row2.createCell(3);
  c23.setCellValue(LocaleUtil.getLocaleCalendar(2013, 06/*zero based*/, 05, 5, 0, 1));
  c23.setCellStyle(style);
  Cell c24 = row2.createCell(4);
  c24.setCellFormula("A3+1");
  c24.setCellValue(3.0d);
  row2.createCell(5).setCellValue(false);
  row2.createCell(6).setCellFormula("B3*20");
  row2.createCell(6).setCellValue("#ERROR");

  // Create third row values
  Row row3 = sheet.createRow(currentRow++);
  row3.createCell(0).setCellValue(3.0);
  row3.createCell(1).setCellValue("Three and Three");
  row3.createCell(5).setCellValue(false);

  // Create fourth row values
  Row row4 = sheet.createRow(currentRow++);
  row4.createCell(0).setCellValue(4.0);
  row4.createCell(1).setCellValue("Four and Four, Five and Five");

  // Create fifth row values
  Row row5 = sheet.createRow(currentRow++);
  row5.createCell(0).setCellValue(5.0);

  sheet.addMergedRegion(new CellRangeAddress(startingRow + 2, startingRow + 2, 1, 2));
  sheet.addMergedRegion(new CellRangeAddress(startingRow + 2, startingRow + 4, 5, 5));
  sheet.addMergedRegion(new CellRangeAddress(startingRow + 3, startingRow + 4, 1, 2));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:54,代码来源:ExcelTestHelper.java


示例5: checkForLocaleChange

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
void checkForLocaleChange() {
    checkForLocaleChange(LocaleUtil.getUserLocale());
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:4,代码来源:ExcelDataFormatter.java


示例6: ExcelHSSFDataFormatter

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
/**
 * Creates a formatter using the {@link Locale#getDefault() default locale}.
 */
public ExcelHSSFDataFormatter() {
    this(LocaleUtil.getUserLocale());
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:7,代码来源:ExcelHSSFDataFormatter.java


示例7: getCellValue

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
/**
 * Retrieves the proper Java type instance based on the Excel CellTypeEnum
 */
private Object getCellValue(Cell cell)
{
	Object value;

	// Empty cells are null, instead of BLANK
	if (cell == null)
	{
		return null;
	}

	switch (cell.getCellTypeEnum())
	{
		case STRING:
			value = cell.getStringCellValue();
			break;
		case NUMERIC:
			if (isCellDateFormatted(cell))
			{
				try
				{
					// Excel dates are LocalDateTime, stored without timezone.
					// Interpret them as UTC to prevent ambiguous DST overlaps which happen in other timezones.
					setUserTimeZone(LocaleUtil.TIMEZONE_UTC);
					Date dateCellValue = cell.getDateCellValue();
					value = formatUTCDateAsLocalDateTime(dateCellValue);
				}
				finally
				{
					resetUserTimeZone();
				}
			}
			else
			{
				value = cell.getNumericCellValue();
			}
			break;
		case BOOLEAN:
			value = cell.getBooleanCellValue();
			break;
		case FORMULA:
			value = getTypedFormulaValue(cell);
			break;
		default:
			value = null;
			break;
	}
	return value;
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:52,代码来源:OneClickImporterServiceImpl.java


示例8: FormatTrackingHSSFListenerPlus

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
/**
 * Creates a format tracking wrapper around the given listener, using
 * the {@link Locale#getDefault() default locale} for the formats.
 *
 * @param childListener the listener to be wrapped
 */
public FormatTrackingHSSFListenerPlus(HSSFListener childListener) {
    this(childListener, LocaleUtil.getUserLocale());
}
 
开发者ID:FlyingHe,项目名称:UtilsMaven,代码行数:10,代码来源:FormatTrackingHSSFListenerPlus.java


示例9: getExcelDate

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
/**
 * Given a Date, converts it into a double representing its internal Excel representation,
 *   which is the number of days since 1/1/1900. Fractional days represent hours, minutes, and seconds.
 *
 * @return Excel representation of Date (-1 if error - aoptest for error by checking for less than 0.1)
 * @param date the Date
 * @param use1904windowing Should 1900 or 1904 date windowing be used?
 */
public static double getExcelDate(Date date, boolean use1904windowing) {
    Calendar calStart = LocaleUtil.getLocaleCalendar();
    calStart.setTime(date);   // If date includes hours, minutes, and seconds, set them to 0
    return internalGetExcelDate(calStart, use1904windowing);
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:14,代码来源:ExcelDateUtil.java


示例10: getJavaCalendarUTC

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
/**
 * Get EXCEL date as Java Calendar with UTC time zone.
 * This is similar to {@link #getJavaDate(double, boolean)} but returns a
 * Calendar object that has UTC as time zone, so no daylight saving hassle.
 * @param date  The Excel date.
 * @param use1904windowing  true if date uses 1904 windowing,
 *  or false if using 1900 date windowing.
 * @return Java representation of the date in UTC, or null if date is not a valid Excel date
 */
public static Calendar getJavaCalendarUTC(double date, boolean use1904windowing) {
	return getJavaCalendar(date, use1904windowing, LocaleUtil.TIMEZONE_UTC, false);
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:13,代码来源:ExcelDateUtil.java


示例11: ExcelDataFormatter

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
/**
 * Creates a formatter using the {@link Locale#getDefault() default locale}.
 *
 * @param  emulateCsv whether to emulate CSV output.
 */
public ExcelDataFormatter(boolean emulateCsv) {
    this(LocaleUtil.getUserLocale(), emulateCsv);
    this.localeIsAdapting = true;
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:10,代码来源:ExcelDataFormatter.java


示例12: ExcelFormatTrackingHSSFListener

import org.apache.poi.util.LocaleUtil; //导入依赖的package包/类
/**
 * Creates a format tracking wrapper around the given listener, using
 * the {@link Locale#getDefault() default locale} for the formats.
 */
public ExcelFormatTrackingHSSFListener(HSSFListener childListener) {
	this(childListener, LocaleUtil.getUserLocale());
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:8,代码来源:ExcelFormatTrackingHSSFListener.java



注:本文中的org.apache.poi.util.LocaleUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MemInfo类代码示例发布时间:2022-05-23
下一篇:
Java DrmSession类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap