楼主我在java拦回答过了,这里的是粘贴错了,如果实施起来有什么问题,就在java拦补充吧
楼主分两种情况,如果你的是时间格式的,string
型的就用楼上方法就好了
opProject.beginDate,那么你要先把它转成string型
<%SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");把时间型转化为string型,假如是现在的时刻,则ss为"2008-4-27"
String ss=sdf.format(opProject.getBeginDate());
String year=ss.substring(0,4);
String year_month=ss.substring(0,7);
String year_month_day=ss;
%>
jsp页面时间的字符串可以采用格式化的方式来处理,这样处理起来效率很高。
实现了对日期的格式化,使用了type、dateStyle、timeStyle等属性。
<%
String date=(opProject.beginDate).toString();
String year=date.substring(0,4);
%>
在你的JSP代码从数据库里面提取出数值以后,用下面的方法截取其前面10位:
opProject.beginDate=opProject.beginDate.substring(0,10)