62,615
社区成员
发帖
与我相关
我的任务
分享
try {
time = format.parse(createTimeStr);
} catch (Exception e) {
out.println("<script>alert('时间参数不对!');history.go(-1);</script>");
}
/**
* Formats a Date into a date/time string.
* @param date the time value to be formatted into a time string.
* @return the formatted time string.
*/
public final String format(Date date)
{
return format(date, new StringBuffer(),
DontCareFieldPosition.INSTANCE).toString();
}
import java.io.UnsupportedEncodingException;
public class Main {
public static void main(String[] Args) throws UnsupportedEncodingException{
java.util.Date date = new java.util.Date();
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd",java.util.Locale.US);
String day = format.format(date);
System.out.println(day);
}
}
format.format(time);
DateFormat format = new SimpleDateFormat("yyyy-mm-dd");
java.util.Date time = null;
<tr>
<td width="100px" align=right class="black12size" valign="top" >
开始时间:
</td>
<td width="300px" class="black12size" style="color:#666666">
<input type="text" name="beginTime" class="bian" ckNull="开始时间不能为空!" style="WIDTH: 150px; HEIGHT: 22px">
</td>
</tr>
String beginTimeStr = request.getParameter("beginTime");
DateFormat format = new SimpleDateFormat("yyyy-mm-dd");
try {
beginTime = format.parse(beginTimeStr);
} catch (Exception e) {
out.println("<script>alert('时间参数不对!');history.go(-1);</script>");
return;
}