RE: Date parsing
I wrote my own date handling class, and it will do what you are looking for: Essentially, to provide a picture for the users you pass in the locale to SaneDate.getDateFormat(). To parse the date, try { new SaneDate(request.getParameter(parm),lc); } catch (InvalidDateException ide) { } http://www.mhsoftware.com/resources/jar/doc/com/MHSoftware/dates/SaneDate.ht ml You can download it from: http://www.mhsoftware.com/bin/MHS.zip George Sexton MH Software, Inc. http://www.mhsoftware.com/ Voice: 303 438 9585 -Original Message- From: Charles P. Killmer [mailto:[EMAIL PROTECTED] Sent: Monday, March 07, 2005 11:17 AM To: Tomcat Users List Subject: Date parsing I have an object with a TimeStamp member. This will be populated by users of a website and entered into a database. My problem is, I would like to allow the users to enter the date in a number of formats. Does anyone have any recommendations aside from multiple try catch blocks each trying to parse the given date with a different expected format? Thanks you for any help, Charles Killmer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date parsing
This has a bunch of useful methods in it. Thank you. However what I am looking for is some class that can handle a date/time string in many different formats and return a date/time object back to me. I tried your code with 3/1/2005 and it worked fine. 3-1-2005 did not. This probably means that locale change is required. Also I tried 3/1/2005 11:45 am, and that failed as well. I am assuming this code was not meant to handle time as well as the date portion. Am I using your code incorrectly, or should I be looking at some other code? Thank You Charles -Original Message- From: George Sexton [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 08, 2005 9:39 AM To: 'Tomcat Users List' Subject: RE: Date parsing I wrote my own date handling class, and it will do what you are looking for: Essentially, to provide a picture for the users you pass in the locale to SaneDate.getDateFormat(). To parse the date, try { new SaneDate(request.getParameter(parm),lc); } catch (InvalidDateException ide) { } http://www.mhsoftware.com/resources/jar/doc/com/MHSoftware/dates/SaneDat e.ht ml You can download it from: http://www.mhsoftware.com/bin/MHS.zip George Sexton MH Software, Inc. http://www.mhsoftware.com/ Voice: 303 438 9585 -Original Message- From: Charles P. Killmer [mailto:[EMAIL PROTECTED] Sent: Monday, March 07, 2005 11:17 AM To: Tomcat Users List Subject: Date parsing I have an object with a TimeStamp member. This will be populated by users of a website and entered into a database. My problem is, I would like to allow the users to enter the date in a number of formats. Does anyone have any recommendations aside from multiple try catch blocks each trying to parse the given date with a different expected format? Thanks you for any help, Charles Killmer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date parsing
Well because of the ambiguities you have to have some expectation of what format the date will be in. What date is 05/12/2005? In the US its May 12th. In Britain it's December 5th. You have to have some expectation and validate against it. The software is designed to use a Locale as an aid to parsing to set up the expectation. In our software, we use the browser's accept-language to retreive a locale. The class as designed doesn't handle times. It's strictly a date class. Im thinking about writing a date/time class, but haven't yet. George Sexton MH Software, Inc. http://www.mhsoftware.com/ Voice: 303 438 9585 -Original Message- From: Charles P. Killmer [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 08, 2005 10:16 AM To: Tomcat Users List Subject: RE: Date parsing This has a bunch of useful methods in it. Thank you. However what I am looking for is some class that can handle a date/time string in many different formats and return a date/time object back to me. I tried your code with 3/1/2005 and it worked fine. 3-1-2005 did not. This probably means that locale change is required. Also I tried 3/1/2005 11:45 am, and that failed as well. I am assuming this code was not meant to handle time as well as the date portion. Am I using your code incorrectly, or should I be looking at some other code? Thank You Charles -Original Message- From: George Sexton [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 08, 2005 9:39 AM To: 'Tomcat Users List' Subject: RE: Date parsing I wrote my own date handling class, and it will do what you are looking for: Essentially, to provide a picture for the users you pass in the locale to SaneDate.getDateFormat(). To parse the date, try { new SaneDate(request.getParameter(parm),lc); } catch (InvalidDateException ide) { } http://www.mhsoftware.com/resources/jar/doc/com/MHSoftware/dat es/SaneDat e.ht ml You can download it from: http://www.mhsoftware.com/bin/MHS.zip George Sexton MH Software, Inc. http://www.mhsoftware.com/ Voice: 303 438 9585 -Original Message- From: Charles P. Killmer [mailto:[EMAIL PROTECTED] Sent: Monday, March 07, 2005 11:17 AM To: Tomcat Users List Subject: Date parsing I have an object with a TimeStamp member. This will be populated by users of a website and entered into a database. My problem is, I would like to allow the users to enter the date in a number of formats. Does anyone have any recommendations aside from multiple try catch blocks each trying to parse the given date with a different expected format? Thanks you for any help, Charles Killmer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date parsing
You could do regular expression field validation. That is, client-side (javascript), build a regular expression object that finds a match for many formats and run the test function on the input string. If true, a match was found, and hence a legal date. The downside is that if you have many date formats, your regular expression could get pretty ugly. Here's the appropriate documentation for IE jscript. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsjsgrpregexpsyntax.asp -Original Message- From: Charles P. Killmer [mailto:[EMAIL PROTECTED] Sent: Monday, March 07, 2005 1:17 PM To: Tomcat Users List Subject: Date parsing I have an object with a TimeStamp member. This will be populated by users of a website and entered into a database. My problem is, I would like to allow the users to enter the date in a number of formats. Does anyone have any recommendations aside from multiple try catch blocks each trying to parse the given date with a different expected format? Thanks you for any help, Charles Killmer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date problem with Tomcat/IIS
Thank you Jann. Expected the constants to be initialised on correct time values, but ok, that's stupid. After all, they are constants... Should have known that. Sorry. Nico
RE: Date problem with Tomcat/IIS
Yes! When you say cal.HOUR_OF_DAY (etc.) you're accessing a CONSTANT in the calendar object. What you want to use is the SimpleDateFormat class. It will do all that you need! Like this: SimpleDateFormat df = new SimpleDateFormat("dd-MM- hh:mm:ss"); then ... retVal = df.format(dt); and it's done! btw: this is a Java problem and has nothing to do with Tomcat or IIS -Original Message- From: H.F.N. den Boer [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 18, 2001 11:55 AM To: Tomcat users group Subject: Date problem with Tomcat/IIS Made a class to do a number of usefull things. One of them is to get the prefix string for a custom servlet-log. In the generated string, the date is correct but the time is always the same. Example of return value: 18-04-2001 11:12:13 I'm working with; Win2K server, build 5.00.2195 IIS 5.0, configured with ISAPI filter JDK1.3.1beta Tomcat 3.2.1 running as NT service Below the code of the servlet. Any ideas ? Nico public String getLogDateTime() { StringBuffer retVal = new StringBuffer(""); Date dt = new Date(); cal = Calendar.getInstance(); cal.setTime(dt); retVal.append(getDateOnlyNumbers(dt)); // add date retVal.append(" "); retVal.append(cal.HOUR_OF_DAY); // add hour retVal.append(":"); retVal.append(cal.MINUTE); // add minute retVal.append(":"); retVal.append(cal.SECOND); // add second retVal.append(" "); return retVal.toString(); }
Re: date
Try the following: String dateString = "03/02/2001"; java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("dd/MM/"); // assuming DMY try { Date d = format.parse(dateString); } catch( java.text.ParseException ex ) {} - Original Message - From: "venkatesan" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: February 3, 2001 4:35 AM Subject: date Hi All, Sorry for this question here can any body tell that to convert a string which represents String ss = "03/02/2001" to Date object.. Again sorry for this question here...Thankx in advance cheers Venkatesh.. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: date
Use the MessageFormat object in java.text.MessageFormat included in the JDK. Peter Thorsager - Original Message - From: "Carlos" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 02, 2001 15:23 Subject: date in jsp how i get the date for print in web in the format XX-XX-XX? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
RE: date
in jsp how i get the date for print in web in the format XX-XX-XX? Works just like any other java class: java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); --- Michael Wentzel Software Developer A HREF="http://www.aswethink.com"Software As We Think/A A HREF="mailto:[EMAIL PROTECTED]"Michael Wentzel/A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: date
On Fri, 2 Feb 2001, Carlos wrote: in jsp how i get the date for print in web in the format XX-XX-XX? java.util.Calendar - but *please* - this is not a Tomcat or even JSP issue. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: date
in a jsp page i have put the next but doesn't run: Why? % java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); % htmlbody % out.println(s); % /body/html thanks Carlos - Original Message - From: "Michael Wentzel" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 02, 2001 2:54 PM Subject: RE: date in jsp how i get the date for print in web in the format XX-XX-XX? Works just like any other java class: java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); --- Michael Wentzel Software Developer A HREF="http://www.aswethink.com"Software As We Think/A A HREF="mailto:[EMAIL PROTECTED]"Michael Wentzel/A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
RE: date
in a jsp page i have put the next but doesn't run: Why? % java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); % htmlbody % out.println(s); % /body/html Give a little more info... Show the stack trace from the tomcat log. Is it a compile error, runtime error,? BTW, instead of: % out.println(s) % try using: %=format(cal.getTime())% won't get rid of your error but it's cleaner. --- Michael Wentzel Software Developer A HREF="http://www.aswethink.com"Software As We Think/A A HREF="mailto:[EMAIL PROTECTED]"Michael Wentzel/A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
RE: date
What is the error message? It could be that if you did not import java.util.* and java.text.*, then it can't find the classes listed after the 'new'. Try it like this : % java.util.GregorianCalendar cal= new java.util.GregorianCalendar(); java.text.SimpleDateFormat format = java.text.new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); % htmlbody % out.println(s); % /body/html -Original Message- From: Carlos [mailto:[EMAIL PROTECTED]] Sent: Friday, February 02, 2001 10:11 AM To: [EMAIL PROTECTED] Subject: Re: date in a jsp page i have put the next but doesn't run: Why? % java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); % htmlbody % out.println(s); % /body/html thanks Carlos - Original Message - From: "Michael Wentzel" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 02, 2001 2:54 PM Subject: RE: date in jsp how i get the date for print in web in the format XX-XX-XX? Works just like any other java class: java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); --- Michael Wentzel Software Developer A HREF="http://www.aswethink.com"Software As We Think/A A HREF="mailto:[EMAIL PROTECTED]"Michael Wentzel/A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
RE: date
Replying to my own post...;P I was just talking to Randy(Layman) about this and we figured that more than likely your problem is the mask value that I gave you in the code snippet is incorrect. In your API docs check out java.text.SimpleDateFormat for the correct masks(javadocs can be your best friend...). --- Michael Wentzel Software Developer A HREF="http://www.aswethink.com"Software As We Think/A A HREF="mailto:[EMAIL PROTECTED]"Michael Wentzel/A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
RE: date
INSTEAD OF: java.text.SimpleDateFormat format = java.text.new SimpleDateFormat("mm-dd-yy"); USE: java.text.SimpleDateFormat format = java.text.new SimpleDateFormat("MM-dd-yy"); "mm" is for minutes, not month -Original Message- From: Michael Wentzel [mailto:[EMAIL PROTECTED]] Sent: Friday, February 02, 2001 8:04 AM To: '[EMAIL PROTECTED]' Subject: RE: date Replying to my own post...;P I was just talking to Randy(Layman) about this and we figured that more than likely your problem is the mask value that I gave you in the code snippet is incorrect. In your API docs check out java.text.SimpleDateFormat for the correct masks(javadocs can be your best friend...). --- Michael Wentzel Software Developer A HREF="http://www.aswethink.com"Software As We Think/A A HREF="mailto:[EMAIL PROTECTED]"Michael Wentzel/A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: date
if i put that in a jsp page appears the next error: how can i get the date? thanks Error: 500 Localizacion: /fecha.jsp Error interno del servlet: org.apache.jasper.JasperException: No se puede compilar la clase para JSP/opt/jakarta/work/www.opticagaldakao.com_8080/_0002ffecha_0002ejspfecha_j sp_0.java:58: Undefined variable or class name: java java.text.SimpleDateFormat format = java.text.new ^ /opt/jakarta/work/www.opticagaldakao.com_8080/_0002ffecha_0002ejspfecha_jsp_ 0.java:59: Class SimpleDateFormat not found. SimpleDateFormat("mm-dd-yy"); ^ /opt/jakarta/work/www.opticagaldakao.com_8080/_0002ffecha_0002ejspfecha_jsp_ 0.java:60: Reference to variable format in class _0002ffecha_0002ejspfecha_jsp_0 as if it were a method. String s = format(cal.getTime()); ^ 3 errors at org.apache.jasper.compiler.Compiler.compile(Compiler.java:254) at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:462) at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146) at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:433) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspSe rvlet.java:152) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja va:164) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404) at org.apache.tomcat.core.Handler.service(Handler.java:286) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79 7) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC onnectionHandler.java:210) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498) at java.lang.Thread.run(Thread.java:484) - Original Message - From: "CPC Livelink Admin" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 02, 2001 4:36 PM Subject: RE: date What is the error message? It could be that if you did not import java.util.* and java.text.*, then it can't find the classes listed after the 'new'. Try it like this : % java.util.GregorianCalendar cal= new java.util.GregorianCalendar(); java.text.SimpleDateFormat format = java.text.new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); % htmlbody % out.println(s); % /body/html -Original Message- From: Carlos [mailto:[EMAIL PROTECTED]] Sent: Friday, February 02, 2001 10:11 AM To: [EMAIL PROTECTED] Subject: Re: date in a jsp page i have put the next but doesn't run: Why? % java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); % htmlbody % out.println(s); % /body/html thanks Carlos - Original Message - From: "Michael Wentzel" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 02, 2001 2:54 PM Subject: RE: date in jsp how i get the date for print in web in the format XX-XX-XX? Works just like any other java class: java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); --- Michael Wentzel Software Developer A HREF="http://www.aswethink.com"Software As We Think/A A HREF="mailto:[EMAIL PROTECTED]"Michael Wentzel/A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
RE: date
Carlos, java.text.SimpleDateFormat myDateFormatter = new java.text.SimpleDateFormat("MM-dd-yy"); String date = myDateFormatter.format( new java.util.Date() ); Cheers, Jin -Original Message- From: Carlos [mailto:[EMAIL PROTECTED]] Sent: Friday, February 02, 2001 11:23 AM To: [EMAIL PROTECTED] Subject: Re: date if i put that in a jsp page appears the next error: how can i get the date? thanks Error: 500 Localizacion: /fecha.jsp Error interno del servlet: org.apache.jasper.JasperException: No se puede compilar la clase para JSP/opt/jakarta/work/www.opticagaldakao.com_8080/_0002ffecha_0002ejspfecha_j sp_0.java:58: Undefined variable or class name: java java.text.SimpleDateFormat format = java.text.new ^ /opt/jakarta/work/www.opticagaldakao.com_8080/_0002ffecha_0002ejspfecha_jsp_ 0.java:59: Class SimpleDateFormat not found. SimpleDateFormat("mm-dd-yy"); ^ /opt/jakarta/work/www.opticagaldakao.com_8080/_0002ffecha_0002ejspfecha_jsp_ 0.java:60: Reference to variable format in class _0002ffecha_0002ejspfecha_jsp_0 as if it were a method. String s = format(cal.getTime()); ^ 3 errors at org.apache.jasper.compiler.Compiler.compile(Compiler.java:254) at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:462) at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146) at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:433) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspSe rvlet.java:152) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja va:164) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404) at org.apache.tomcat.core.Handler.service(Handler.java:286) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79 7) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC onnectionHandler.java:210) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498) at java.lang.Thread.run(Thread.java:484) - Original Message - From: "CPC Livelink Admin" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 02, 2001 4:36 PM Subject: RE: date What is the error message? It could be that if you did not import java.util.* and java.text.*, then it can't find the classes listed after the 'new'. Try it like this : % java.util.GregorianCalendar cal= new java.util.GregorianCalendar(); java.text.SimpleDateFormat format = java.text.new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); % htmlbody % out.println(s); % /body/html -Original Message- From: Carlos [mailto:[EMAIL PROTECTED]] Sent: Friday, February 02, 2001 10:11 AM To: [EMAIL PROTECTED] Subject: Re: date in a jsp page i have put the next but doesn't run: Why? % java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); % htmlbody % out.println(s); % /body/html thanks Carlos - Original Message - From: "Michael Wentzel" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 02, 2001 2:54 PM Subject: RE: date in jsp how i get the date for print in web in the format XX-XX-XX? Works just like any other java class: java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); --- Michael Wentzel Software Developer A HREF="http://www.aswethink.com"Software As We Think/A A HREF="mailto:[EMAIL PROTECTED]"Michael Wentzel/A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] --
RE: date
Corrected code: java.util.Calendar cal= new java.util.GregorianCalendar(); java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("MM-dd-yy"); String s = format.format(cal.getTime()); Double check the mask is really what you want. -Original Message- From: Carlos [mailto:[EMAIL PROTECTED]] Sent: Friday, February 02, 2001 11:23 AM To: [EMAIL PROTECTED] Subject: Re: date if i put that in a jsp page appears the next error: how can i get the date? thanks Error: 500 Localizacion: /fecha.jsp Error interno del servlet: org.apache.jasper.JasperException: No se puede compilar la clase para JSP/opt/jakarta/work/www.opticagaldakao.com_8080/_0002ffecha_0002ejspfecha_j sp_0.java:58: Undefined variable or class name: java java.text.SimpleDateFormat format = java.text.new ^ /opt/jakarta/work/www.opticagaldakao.com_8080/_0002ffecha_0002ejspfecha_jsp_ 0.java:59: Class SimpleDateFormat not found. SimpleDateFormat("mm-dd-yy"); ^ /opt/jakarta/work/www.opticagaldakao.com_8080/_0002ffecha_0002ejspfecha_jsp_ 0.java:60: Reference to variable format in class _0002ffecha_0002ejspfecha_jsp_0 as if it were a method. String s = format(cal.getTime()); ^ 3 errors at org.apache.jasper.compiler.Compiler.compile(Compiler.java:254) at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:462) at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146) at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:433) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspSe rvlet.java:152) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja va:164) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404) at org.apache.tomcat.core.Handler.service(Handler.java:286) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79 7) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC onnectionHandler.java:210) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498) at java.lang.Thread.run(Thread.java:484) - Original Message - From: "CPC Livelink Admin" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 02, 2001 4:36 PM Subject: RE: date What is the error message? It could be that if you did not import java.util.* and java.text.*, then it can't find the classes listed after the 'new'. Try it like this : % java.util.GregorianCalendar cal= new java.util.GregorianCalendar(); java.text.SimpleDateFormat format = java.text.new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); % htmlbody % out.println(s); % /body/html -Original Message- From: Carlos [mailto:[EMAIL PROTECTED]] Sent: Friday, February 02, 2001 10:11 AM To: [EMAIL PROTECTED] Subject: Re: date in a jsp page i have put the next but doesn't run: Why? % java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); % htmlbody % out.println(s); % /body/html thanks Carlos - Original Message - From: "Michael Wentzel" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 02, 2001 2:54 PM Subject: RE: date in jsp how i get the date for print in web in the format XX-XX-XX? Works just like any other java class: java.util.GregorianCalendar cal= new GregorianCalendar(); java.text.SimpleDateFormat format = new SimpleDateFormat("mm-dd-yy"); String s = format(cal.getTime()); --- Michael Wentzel Software Developer A HREF="http://www.aswethink.com"Software As We Think/A A HREF="mailto:[EMAIL PROTECTED]"Michael Wentzel/A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - T