国际化 格式化
来源:互联网 发布:网络运维工作内容 编辑:程序博客网 时间:2024/05/22 15:00
1、请编写一个能国际化显示的登陆页面
<%@ page Xlanguage="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'Second.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<fmt:setLocale value="zh"/>
<fmt:setBundle basename="com.csdn.hbsi.Resource.myresource"/>
<form action="">
<fmt:message key="username"/>
<input type="text" name="username">
<br>
<fmt:message key="password"/>
<input type="password" name="password">
<br>
<input type="submit" value=""/>
</form>
</body>
</html>
2、请创建一个date对象,并把date对象中表示日期部分的时间值,以及表示时间部分的时间值,分别以short、long模式进行格式化输出(国家设置为中国)。
package com.csdn.hbsi.test;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
public class Demo2 {
/**
* @param args
*/
public static void main(String[] args) {
Date d=new Date();
DateFormat df=DateFormat.getDateInstance(DateFormat.SHORT,Locale.CHINA);
String result=df.format(d);
System.out.println(result);
df=DateFormat.getTimeInstance(DateFormat.LONG,Locale.CHINA);
result=df.format(d);
System.out.println(result);
}
}
3、请将时间值:09-11-28 上午10时25分39秒 CST,反向解析成一个date对象。
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.Locale;
public class Demo3 {
/**
* @param args
*/
public static void main(String[] args) {
String s="09-11-28 上午10时25分39秒 CST";
DateFormat df=DateFormat.getTimeInstance(DateFormat.FULL, Locale.CHINA);
try {
Date d=df.parse(s);
System.out.println(d);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
4、请将整数198,输出为货币形式:$198,并将$198反向解析成整数198。
package com.csdn.hbsi.test;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
public class huobi {
/**
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
double db=198;
NumberFormat nf=NumberFormat.getCurrencyInstance(Locale.US);
String result=nf.format(db);
System.out.println(result);
String s="$198";
nf=NumberFormat.getCurrencyInstance(Locale.US);
Number n=nf.parse(s);
double db1=n.doubleValue();
System.out.println(db1);
<%@ page Xlanguage="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'Second.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<fmt:setLocale value="zh"/>
<fmt:setBundle basename="com.csdn.hbsi.Resource.myresource"/>
<form action="">
<fmt:message key="username"/>
<input type="text" name="username">
<br>
<fmt:message key="password"/>
<input type="password" name="password">
<br>
<input type="submit" value=""/>
</form>
</body>
</html>
2、请创建一个date对象,并把date对象中表示日期部分的时间值,以及表示时间部分的时间值,分别以short、long模式进行格式化输出(国家设置为中国)。
package com.csdn.hbsi.test;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
public class Demo2 {
/**
* @param args
*/
public static void main(String[] args) {
Date d=new Date();
DateFormat df=DateFormat.getDateInstance(DateFormat.SHORT,Locale.CHINA);
String result=df.format(d);
System.out.println(result);
df=DateFormat.getTimeInstance(DateFormat.LONG,Locale.CHINA);
result=df.format(d);
System.out.println(result);
}
}
3、请将时间值:09-11-28 上午10时25分39秒 CST,反向解析成一个date对象。
package com.csdn.hbsi.test;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.Locale;
public class Demo3 {
/**
* @param args
*/
public static void main(String[] args) {
String s="09-11-28 上午10时25分39秒 CST";
DateFormat df=DateFormat.getTimeInstance(DateFormat.FULL, Locale.CHINA);
try {
Date d=df.parse(s);
System.out.println(d);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
4、请将整数198,输出为货币形式:$198,并将$198反向解析成整数198。
package com.csdn.hbsi.test;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
public class huobi {
/**
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
double db=198;
NumberFormat nf=NumberFormat.getCurrencyInstance(Locale.US);
String result=nf.format(db);
System.out.println(result);
String s="$198";
nf=NumberFormat.getCurrencyInstance(Locale.US);
Number n=nf.parse(s);
double db1=n.doubleValue();
System.out.println(db1);
- 国际化 格式化
- javaweb国际化/格式化标签
- 国际化/格式化标签
- 国际化-日期格式化
- 国际化-数字格式化
- Struts2 的国际化&格式化数据
- 国际化与格式化(2):MessageFormat
- jsp国际化/格式化标签库
- Chapter03 国际化(五) 消息格式化
- 国际化与格式化(1):完成程序的国际化
- JAVA 数字格式化处理方法; 国际化
- JSP 国际化-格式化货币和日期
- 软件国际化之日期,数字,消息格式化
- 黑马day13 国际化之日期&货币格式化
- easyui 格式化日期以及国际化的引用
- JSP 国际化--格式化货币和日期
- javaweb国际化/格式化标签的综合实例代码
- java国际化——消息格式化+文本文件和字符集
- 《CSS设计彻底研究》读书笔记 第04章 盒子的浮动与定位
- Thread.UncaughtExceptionHandler
- 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项, Vs2010连接的问题
- 表空间信息查询
- 管人管理<制度与管理>
- 国际化 格式化
- 64位的ubuntu,不安装32位库,会导致无法创建android模拟器
- C#设计模式之代理模式(二)
- 包装类 与 简单集合框架
- socket函数集-----网络编程必备值得拥有
- 初识Antlr,就以失败来打击我
- PL/SQLDeveloper使用技巧小结
- ARM汇编程序---ARM汇编实现简单判断环习题
- 图像的空间域与频率域