Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Simply a date


Message #1 by "Steve Rioux" <riouste@b...> on Tue, 1 May 2001 18:26:06
Thanks for the observation, I missed the "<%" in my code.

should be:

<%@ page import="java.util.Calendar" %>
<%!String my_Date;%>//for scope purposes

<%
java.util.Calendar now = Calendar.getInstance();
int month = now.get(Calendar.MONTH);
month++;//a must do instruction..
int day =  now.get(Calendar.DAY_OF_MONTH);
int year = now.get(Calendar.YEAR);
my_Date=day+"/"+month+"/"+year;
%>
<%=my_Date%>

Let me know if i am missing something.


> please take a look at SimpleDateFormat. It's a much better solution.
> And on top of that, you're using <%! %> tags incorrectly.
> Why on earth are you declaring the my_date (should be lowerCase-
CamelCase:
> myDate) in <%!  %> tags????? It will make you have concurrency errors.
> 
> Geert Van Damme
> 
> 
> > -----Original Message-----
> > From: Daniel Herrera Díaz [mailto:daniel@d...]
> > Sent: woensdag 2 mei 2001 14:04
> > To: Pro_JavaServer_Pages
> > Subject: [pro_jsp] Re: Simply a date
> >
> >
> > try this..
> >
> >
> > <%@ page import="java.util.Calendar" %>
> > <%!String my_date;%>
> > java.util.Calendar now = Calendar.getInstance();
> > int month = now.get(Calendar.MONTH);
> > month++;//a must do instruction..
> > int day =  now.get(Calendar.DAY_OF_MONTH);
> > int year = now.get(Calendar.YEAR);
> > my_date=day+"/"+month+"/"+year;
> > %>
> > <%=my_date%>
> >
> > HTH
> > Daniel Herrera

  Return to Index