Java Code Examples for cn.hutool.core.date.DateUtil#formatTime()

The following examples show how to use cn.hutool.core.date.DateUtil#formatTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UseHutool.java    From java-tutorial with MIT License 6 votes vote down vote up
/**
 * hutool 时间格式化
 */
public static void dateFormat() {

    String dateStr = "2017-03-01";
    Date date = DateUtil.parse(dateStr);
    //结果 2017/03/01
    String format = DateUtil.format(date, "yyyy/MM/dd");
    //常用格式的格式化,结果:2017-03-01
    String formatDate = DateUtil.formatDate(date);
    //结果:2017-03-01 00:00:00
    String formatDateTime = DateUtil.formatDateTime(date);
    //结果:00:00:00
    String formatTime = DateUtil.formatTime(date);
    System.out.println(format);
    System.out.println(formatDate);
    System.out.println(formatDateTime);
    System.out.println(formatTime);
}
 
Example 2
Source File: TopManager.java    From Jpom with MIT License 5 votes vote down vote up
public static Iterator<CacheObj<String, JSONObject>> get() {
    JSONObject topInfo = AbstractSystemCommander.getInstance().getAllMonitor();
    if (topInfo != null) {
        DateTime date = DateUtil.date();
        String time = DateUtil.formatTime(date);
        topInfo.put("time", time);
        topInfo.put("monitorTime", date.getTime());
        MONITOR_CACHE.put(time, topInfo);
    }
    return MONITOR_CACHE.cacheObjIterator();
}
 
Example 3
Source File: StringUtil.java    From Jpom with MIT License 5 votes vote down vote up
/**
 * 指定时间的下一个刻度
 *
 * @return String
 */
public static String getNextScaleTime(String time, Long millis) {
    DateTime dateTime = DateUtil.parseTime(time);
    if (millis == null) {
        millis = 30 * 1000L;
    }
    DateTime newTime = dateTime.offsetNew(DateField.SECOND, (int) (millis / 1000));
    return DateUtil.formatTime(newTime);
}