<%@ page import=\"java.util.*, java.text.*\" %>
??ò×?μí3μ±?°ê±???a£o
<%
Date now = new Date();
DateFormat defaultFormat = DateFormat.getDateInstance();
DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT);
DateFormat mediumFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
DateFormat longFormat = DateFormat.getDateInstance(DateFormat.LONG);
DateFormat fullFormat = DateFormat.getDateInstance(DateFormat.FULL);
SimpleDateFormat sDateFormat=new SimpleDateFormat(\”yyyy?êMM??DDè?\”);
SimpleDateFormat String2Date=new SimpleDateFormat(\”yyyy-mm-dd\”);
Date S2Date=String2Date.parse(\”2004-07-28\”);
String defaultDate = defaultFormat.format(now);
String shortDate = shortFormat.format(now);
String mediumDate = mediumFormat.format(now);
String longDate = longFormat.format(now);
String fullDate = fullFormat.format(now);
//out.println(DateFormat.getTimeInstance().format(now));
out.println(shortDate);
out.println(sDateFormat.format(S2Date));
%>
import java.util.Date;
public class DateExample3 {
public static void main(String[] args) {
// Create a date formatter that can parse dates of
// the form MM-dd-yyyy.
SimpleDateFormat bartDateFormat =
new SimpleDateFormat(\”MM-dd-yyyy\”);
// Create a string containing a text date to be parsed.
String dateStringToParse = \”9-29-2001\”;
try {
// Parse the text version of the date.
// We have to perform the parse method in a
// try-catch construct in case dateStringToParse
// does not contain a date in the format we are expecting.
Date date = bartDateFormat.parse(dateStringToParse);
// Now send the parsed date as a long value
// to the system output.
System.out.println(date.getTime());
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
}
我就是未分类