import java.util.Calendar; /** * Copyright 2009 XXX, Inc. All Rights Reserved. * Class Test.java
说明 * @file Test.java * @author wz-03016 * @created 2009-7-16 * @version v1.0 * @see .Test.java * @revision */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; import java.util.GregorianCalendar; public class DateUtil { public DateUtil(){} /** * @see 取得当前日期(格式为:yyyy-MM-dd) * @return String */ public String GetDate() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String sDate = sdf.format(new Date()); return sDate; } /** * @see 取得当前时间(格式为:yyy-MM-dd HH:mm:ss) * @return String */ public static String GetDateTime() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String sDate = sdf.format(new Date()); return sDate; } /** * @see 按指定格式取得当前时间() * @return String */ public String GetTimeFormat(String strFormat) { SimpleDateFormat sdf = new SimpleDateFormat(strFormat); String sDate = sdf.format(new Date()); return sDate; } /** * @see 取得指定时间的给定格式() * @return String * @throws ParseException */ public String SetDateFormat(String myDate,String strFormat) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat(strFormat); String sDate = sdf.format(sdf.parse(myDate)); return sDate; } public String FormatDateTime(String strDateTime, String strFormat) { String sDateTime = strDateTime; try { Calendar Cal = parseDateTime(strDateTime); SimpleDateFormat sdf = null; sdf = new SimpleDateFormat(strFormat); sDateTime = sdf.format(Cal.getTime()); } catch (Exception e) { } return sDateTime; } public static C
java 周次_java处理年、月、周次以及起至日期大全
最新推荐文章于 2023-10-12 14:43:20 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)