tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raphaël Lemaitre <raph...@e-deal.com>
Subject Internationalization problem
Date Mon, 08 Jan 2001 19:46:45 GMT
Hi,

	I got a problem with i18n. I want to use a french localized
GregorianCalendar but when i execute my JSP, the GregorianCalendar is not
French Localized. I use jakarta-tomcat 3.2 with Sun JDK 1.3; On the other
hand, when i execute the same code in a java application (with sun JVM 1.3),
the result is exactly wath i expect. What am i missing in jakarta
configuration?

Here are the source code and the result of my JSP and the java app

testCalendar.jsp:
*****************************

<%@page session="true" import="java.text.*, java.util.*"%>
<html>
<head>
</head>
<BODY TEXT="000000" BGCOLOR="EBF2F1" LINK="501123" ALINK="501123"
VLINK="501123">
<%
	Vector days = new Vector();
	Vector weeks = new Vector();
	java.text.SimpleDateFormat sdf = new SimpleDateFormat("EEEE",
Locale.FRANCE);
	java.text.SimpleDateFormat sdf2 = new SimpleDateFormat("dd/MM/yyyy",
Locale.FRANCE);
	GregorianCalendar myCalendar = new GregorianCalendar(Locale.FRANCE);
	myCalendar.setTime(sdf2.parse("05/01/2001"));
	myCalendar.set(myCalendar.DAY_OF_WEEK,
myCalendar.getFirstDayOfWeek());
	for (int i = 0; i < 4; i++) {
		weeks.addElement(new
Integer(myCalendar.get(myCalendar.WEEK_OF_YEAR)));
		for (int j = 0; j < 7; j++) {
			days.addElement(myCalendar.getTime());
			myCalendar.setTime(new
Date(myCalendar.getTime().getTime() + (1000*60*60*24)));
		}
	}
%>
<table>
	<tr>
		<td></td>
		<%
		for (int j = 0; j < 7; j++) {
		%>
		<td>
			<%=sdf.format((Date) days.elementAt(j))%>
		</td>
		<%}%>
	</tr>
	<%for (int i = 0; i < 4; i++) {%>
	<tr>
		<td>
			<%=weeks.elementAt(i)%>
		</td>
		<%for (int j = 0; j < 7; j++) {%>
		<td>
			<%=sdf2.format((Date) days.elementAt(7 * i + j))%>
		</td>
		<%}%>
	</tr>
	<%}%>
</table>
</body>
</html>

the result is :
	Sunday	Monday	Tuesday	Wednesday	Thursday	Friday
Saturday 
1	31/12/2000	01/01/2001	02/01/2001	03/01/2001
04/01/2001	05/01/2001	06/01/2001 
2	07/01/2001	08/01/2001	09/01/2001	10/01/2001
11/01/2001	12/01/2001	13/01/2001 
3	14/01/2001	15/01/2001	16/01/2001	17/01/2001
18/01/2001	19/01/2001	20/01/2001 
4	21/01/2001	22/01/2001	23/01/2001	24/01/2001
25/01/2001	26/01/2001	27/01/2001 

testCalendar.java
*****************************
import java.text.*;
import java.util.*;

public class TestCalendar {
	public static void main(java.lang.String[] args) {
		Vector days = new Vector();
		Vector weeks = new Vector();
		SimpleDateFormat sdf = new SimpleDateFormat("EEEE",
Locale.FRANCE);
		SimpleDateFormat sdf2 = new SimpleDateFormat("dd/MM/yyyy",
Locale.FRANCE);
		GregorianCalendar myCalendar = new
GregorianCalendar(Locale.FRANCE);
		myCalendar.setTime(sdf2.parse("05/01/2001"));
		myCalendar.set(myCalendar.DAY_OF_WEEK,
myCalendar.getFirstDayOfWeek());
		for (int i = 0; i < 4; i++) {
			weeks.addElement(new
Integer(myCalendar.get(myCalendar.WEEK_OF_YEAR)));
			for (int j = 0; j < 7; j++) {
				days.addElement(myCalendar.getTime());
				myCalendar.setTime(new
Date(myCalendar.getTime().getTime() + (1000*60*60*24)));
			}
		}
		System.out.print("\t");
		for (int j = 0; j < 7; j++) {
			System.out.print(sdf.format((Date)
days.elementAt(j)) + "\t");
		}
		System.out.println();
		for (int i = 0; i < 4; i++) {
			System.out.print(weeks.elementAt(i) + "\t");
			for (int j = 0; j < 7; j++) {
				System.out.print(sdf2.format((Date)
days.elementAt(7 * i + j)) + "\t");
			}
			System.out.println();
		}
	}
}

and the result is :

	lundi		mardi		mercredi	jeudi
vendredi	samedi	dimanche	
1	01/01/2001	02/01/2001	03/01/2001	04/01/2001
05/01/2001	06/01/2001	07/01/2001	
2	08/01/2001	09/01/2001	10/01/2001	11/01/2001
12/01/2001	13/01/2001	14/01/2001	
3	15/01/2001	16/01/2001	17/01/2001	18/01/2001
19/01/2001	20/01/2001	21/01/2001	
4	22/01/2001	23/01/2001	24/01/2001	25/01/2001
26/01/2001	27/01/2001	28/01/2001	

--
Raphaël LEMAITRE 
mailto:raphael.lemaitre@e-deal.com 
e-deal 
86-88 rue du Vieux Pont, 92000 Nanterre 
http://www.e-deal.com + 33.1.41.37.91.00 

Mime
View raw message