use of java.text.SimpleDateFormat in project translationstudio8 by heartsome.
the class DateUtilsBasic method getStringToday.
/**
* 得到现在的时间字符串.
* @return String
* 时间字符串格式 yyyyMMdd HHmmss
*/
public static String getStringToday() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd HHmmss");
String dateString = formatter.format(currentTime);
return dateString;
}
use of java.text.SimpleDateFormat in project translationstudio8 by heartsome.
the class DateUtilsBasic method strToDateLong.
/**
* 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss.
* @param strDate
* 指定的日期字符串
* @return Date
* 返回时间类型 yyyy-MM-dd HH:mm:ss
*/
public static Date strToDateLong(String strDate) {
if (strDate == null) {
return null;
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
use of java.text.SimpleDateFormat in project translationstudio8 by heartsome.
the class DateUtilsBasic method getHour.
/**
* 得到现在小时.如当前时间为 14:45:55,则返回 14
* @return String
* 当前时间的小时数
*/
public static String getHour() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
String hour;
hour = dateString.substring(11, 13);
return hour;
}
use of java.text.SimpleDateFormat in project translationstudio8 by heartsome.
the class DateUtilsBasic method dateToStrLong.
/**
* 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss.
* @param dateDate
* 指定的日期
* @return String
* 返回时间字符串 yyyy-MM-dd HH:mm:ss
*/
public static String dateToStrLong(java.util.Date dateDate) {
if (dateDate == null) {
dateDate = new Date();
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(dateDate);
return dateString;
}
use of java.text.SimpleDateFormat in project translationstudio8 by heartsome.
the class DateUtilsBasic method getTimeShort.
/**
* 获取时间 小时:分;秒 HH:mm:ss.
* @return String
* 返回短时间字符串格式 HH:mm:ss.
*/
public static String getTimeShort() {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date currentTime = new Date();
String dateString = formatter.format(currentTime);
return dateString;
}
Aggregations