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);