//获得年份intyear =c1.get(Calendar.YEAR);//获得月份intmonth = c1.get(Calendar.MONTH) + 1;//获得日期intdate =c1.get(Calendar.DATE);//获得小时inthour =c1.get(Calendar.HOUR_OF_DAY);//获得分钟intminute =c1.get(Calendar.MINUTE);//获得秒intsecond =c1.get(Calendar.SECOND);//获得星期几(...
// 定义时间格式DateTimeFormatterformatter=DateTimeFormatter.ofPattern("HH:mm:ss.SSS");StringformattedTime=currentTime.format(formatter); 1. 2. 3. 步骤三:获取时分秒毫秒 最后,我们可以从格式化后的时间中获取时、分、秒和毫秒。 // 获取时inthour=currentTime.getHour();// 获取分intminute=currentTime.ge...
DateFormat df3 = DateFormat.getTimeInstance(); System.out.println(df3.format(date)); //显示日期,周,上下午,时间(精确到秒) //2017年4月16日 星期日 下午12时43分37秒 CST DateFormat df4 = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); System.out.println(df4.format(date)...
importjava.text.SimpleDateFormat;publicclassDateUtils{publicstaticDategetCurrentDate(){DatecurrentDate=newDate();returncurrentDate;}publicstaticStringformatDateTime(Datedate){SimpleDateFormatformatter=newSimpleDateFormat("yyyy-MM-dd HH:mm:ss");StringformattedDateTime=formatter.format(date);returnformattedDate...
final static DateFormat getDateInstance(int style) final static DateFormat getDateInstance(int style, Locale locale) final static DateFormat getTimeInstance() final static DateFormat getTimeInstance(int style) final static DateFormat getTimeInstance(int style, Locale locale) ...
This is equivalent to calling #getDateInstance(int, Locale) getDateInstance(style, Locale.getDefault(Locale.Category.FORMAT)). Java documentation for java.text.DateFormat.getDateInstance(int). Portions of this page are modifications based on work created and shared by the Android Open Source Project ...
This is equivalent to calling#getDateInstance(int, Locale) getDateInstance(style, Locale.getDefault(Locale.Category.FORMAT)). Java documentation forjava.text.DateFormat.getDateInstance(int). Portions of this page are modifications based on work created and shared by theAndroid Open Source Projectand use...
DateFormat 构造函数 字段 属性 方法 Format GetAvailableLocales GetDateInstance GetDateTimeInstance GetTimeInstance Parse ParseObject DateFormat.Field DateFormatSymbols DecimalFormat DecimalFormatSymbols FieldPosition IAttributedCharacterIterator ICharacterIterator
Gets the date formatter with the given formatting style for the defaultjava.util.Locale.Category#FORMAT FORMATlocale. This is equivalent to calling#getDateInstance(int, Locale) getDateInstance(style, Locale.getDefault(Locale.Category.FORMAT)).
To get local formatting use getDateInstance() , getDateTimeInstance() , or getTimeInstance() , or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII 日期。