import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.htmlparser.Node;
import org.htmlparser.Parser;
import org.htmlparser.filters.AndFilter;
import org.htmlparser.filters.HasAttributeFilter;
import org.htmlparser.filters.TagNameFilter;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;
import com.sun.org.apache.bcel.internal.generic.NEW;
public class test {
public static void main(String[] args) throws HttpException, IOException, ParserException {
// TODO Auto-generated method stub
//时间转换:
String strSourcePattern = "yyyy-MM-dd HH:mm:ss";
String strDestPattern = "yyyy-MM-dd";
String strTime = "2012-06-12 04:00:00";
try {
SimpleDateFormat sourceDateFormat = new SimpleDateFormat(strSourcePattern, Locale.US);
SimpleDateFormat destDateFormat = new SimpleDateFormat(strDestPattern, Locale.US);
Date date = sourceDateFormat.parse(strTime);
System.out.println(destDateFormat.format(date));
} catch (ParseException e) {
}
}
}
java 时间格式转换
最新推荐文章于 2023-01-04 13:52:46 发布