この記事では、リファレンスのDateUtil Tool Time Time Type Typeの変換の特定のコードを共有しています。特定のコンテンツは次のとおりです
パッケージcom.sinosoft.media.sms.util; java.text.parseexceptionをインポートします。 java.text.simpledateformatをインポートします。 Import Java.util.date; public class dateutil {//現在の時間// public static date date_now = new date(); / ***完全なタイムスタンプ、フォーマット:yyyymmdhhmmmssssss(年、月、1日、秒、秒、milliseconds) } / ***シンプルなタイムスタンプを取得します。フォーマット:yyyymmdd(year、month、day)* @return simple Timestamp* / public static string getsimpletimestamp(){return new simpledateformat( "yyyymmdd")。フォーマット(new Date()); } / ***指定された形式に基づいてタイムスタンプを取得* @paramパターン指定形式* @returnタイムスタンプの指定された形式* / public static string getTimestampBypattern(String Pattern){return new SimpledAteFormat(pattern).format(new Date()); } / ***現在の日付でフォーマットされた文字列を取得します:yyyy-mm-dd(year-month-day)* @ @return現在の日付でフォーマットされた文字列* / public static string gettodaystr(){return new simpledateformat( "yyyy-mm-dd")。 } / ***タイムスタンプ、フォーマット:yyyy-mm-dd hh:mm:mm:ss(year-month-day-time:minutes:sconeds)* @return simple timestamp* / public static string getdateTimestamp(日付){return new simpledateformat( "yyyy-mm-dd hh:ss")。 } public static date getDateByString(String str){simpledateFormat sim = new simpledateFormat( "yyyy-mm-dd hh:mm:ss");日付dateTime = null; try {dateTime = sim.parse(str); } catch(parseexception e){e.printstacktrace(); } dateTimeを返します。 }}上記はこの記事のすべての内容です。みんなの学習に役立つことを願っています。誰もがwulin.comをもっとサポートすることを願っています。