Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url映射到controller时,关于HandlerMapping的getHandler() #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 126 additions & 126 deletions fast-core/src/main/java/org/fastframework/core/util/TimeUtil.java
Original file line number Diff line number Diff line change
@@ -1,126 +1,126 @@
package org.fastframework.core.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
* 基于 JDK 8 time包的时间工具类
* <p>
* Created by bysocket on 16/8/23.
*/
public class TimeUtil {

/**
* 默认时间格式
*/
private static final String SHORT_DATE_PATTERN_DEFAULT = "yyyy-MM-dd";
private static final String LONG_DATE_PATTERN_DEFAULT = "yyyy-MM-dd HH:mm:ss";
private static final String LONG_DATE_PATTERN_WITH_MILSEC_DEFAULT = "yyyy-MM-dd HH:mm:ss.SSS";

/**
* 短时间格式 : 2016-08-25
*/
private static final String[] SHORT_DATE_PATTERN = {"yyyy-MM-dd",
"yyyy/MM/dd",
"yyyy\\MM\\dd",
"yyyyMMdd"};
/**
* 长时间格式 : 2016-08-25 20:28:46
*/
private static final String[] LONG_DATE_PATTERN = {"yyyy-MM-dd HH:mm:ss",
"yyyy/MM/dd HH:mm:ss",
"yyyy\\MM\\dd HH:mm:ss",
"yyyyMMddHHmmss"};
/**
* 长时间格式 ( 带毫秒 ) : 2016-08-25 20:34:48.956
*/
private static final String[] LONG_DATE_PATTERN_WITH_MILSEC = {"yyyy-MM-dd HH:mm:ss.SSS",
"yyyy/MM/dd HH:mm:ss.SSS",
"yyyy\\MM\\dd HH:mm:ss.SSS",
"yyyyMMddHHmmssSSS"};

/**
* String 转时间
*
* @param timeStr
* @return
*/
public final static LocalDateTime parseTime(String timeStr) {
LocalDateTime dateTime = LocalDateTime.parse(timeStr, getDefaultDateTimeFormatter());
return dateTime;
}

/**
* String 转时间
*
* @param timeStr
* @param format 时间格式
* @return
*/
public final static LocalDateTime parseTime(String timeStr, String format) {
LocalDateTime dateTime = LocalDateTime.parse(timeStr, getDateTimeFormatter(format));
return dateTime;
}

/**
* 时间转 String
*
* @param time
* @return
*/
public final static String parseTime(LocalDateTime time) {
return getDefaultDateTimeFormatter().format(time);
}

/**
* 时间转 String
*
* @param time
* @param format 时间格式
* @return
*/
public final static String parseTime(LocalDateTime time, String format) {
return getDateTimeFormatter(format).format(time);
}

/**
* 获取当前时间
*
* @return
*/
public final static String getCurrentDatetime() {
LocalDateTime now = LocalDateTime.now();
return getDefaultDateTimeFormatter().format(now);
}

/**
* 获取当前时间
*
* @param format 时间格式
* @return
*/
public final static String getCurrentDatetime(String format) {
LocalDateTime now = LocalDateTime.now();
return getDateTimeFormatter(format).format(now);
}

/**
* 获取默认时间格式
*
* @return
*/
private final static DateTimeFormatter getDefaultDateTimeFormatter() {
return DateTimeFormatter.ofPattern(LONG_DATE_PATTERN_DEFAULT);
}

/**
* 获取时间格式
*
* @param format 时间格式
* @return
*/
private final static DateTimeFormatter getDateTimeFormatter(String format) {
return DateTimeFormatter.ofPattern(format);
}

}
package org.fastframework.core.util;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* 基于 JDK 8 time包的时间工具类
* <p>
* Created by bysocket on 16/8/23.
*/
public class TimeUtil {
/**
* 默认时间格式
*/
public static final String SHORT_DATE_PATTERN_DEFAULT = "yyyy-MM-dd";
public static final String LONG_DATE_PATTERN_DEFAULT = "yyyy-MM-dd HH:mm:ss";
public static final String LONG_DATE_PATTERN_WITH_MILSEC_DEFAULT = "yyyy-MM-dd HH:mm:ss.SSS";
/**
* 短时间格式 : 2016-08-25
*/
public static final String[] SHORT_DATE_PATTERN = {"yyyy-MM-dd",
"yyyy/MM/dd",
"yyyy\\MM\\dd",
"yyyyMMdd"};
/**
* 长时间格式 : 2016-08-25 20:28:46
*/
public static final String[] LONG_DATE_PATTERN = {"yyyy-MM-dd HH:mm:ss",
"yyyy/MM/dd HH:mm:ss",
"yyyy\\MM\\dd HH:mm:ss",
"yyyyMMddHHmmss"};
/**
* 长时间格式 ( 带毫秒 ) : 2016-08-25 20:34:48.956
*/
public static final String[] LONG_DATE_PATTERN_WITH_MILSEC = {"yyyy-MM-dd HH:mm:ss.SSS",
"yyyy/MM/dd HH:mm:ss.SSS",
"yyyy\\MM\\dd HH:mm:ss.SSS",
"yyyyMMddHHmmssSSS"};
/**
* String 转时间
*
* @param timeStr
* @return
*/
public final static LocalDateTime parseTime(String timeStr) {
LocalDateTime dateTime = LocalDateTime.parse(timeStr, getDefaultDateTimeFormatter());
return dateTime;
}
/**
* String 转时间
*
* @param timeStr
* @param format 时间格式
* @return
*/
public final static LocalDateTime parseTime(String timeStr, String format) {
LocalDateTime dateTime = LocalDateTime.parse(timeStr, getDateTimeFormatter(format));
return dateTime;
}
/**
* 时间转 String
*
* @param time
* @return
*/
public final static String parseTime(LocalDateTime time) {
return getDefaultDateTimeFormatter().format(time);
}
/**
* 时间转 String
*
* @param time
* @param format 时间格式
* @return
*/
public final static String parseTime(LocalDateTime time, String format) {
return getDateTimeFormatter(format).format(time);
}
/**
* 获取当前时间
*
* @return
*/
public final static String getCurrentDatetime() {
LocalDateTime now = LocalDateTime.now();
return getDefaultDateTimeFormatter().format(now);
}
/**
* 获取当前时间
*
* @param format 时间格式
* @return
*/
public final static String getCurrentDatetime(String format) {
LocalDateTime now = LocalDateTime.now();
return getDateTimeFormatter(format).format(now);
}
/**
* 获取默认时间格式
*
* @return
*/
private final static DateTimeFormatter getDefaultDateTimeFormatter() {
return DateTimeFormatter.ofPattern(LONG_DATE_PATTERN_DEFAULT);
}
/**
* 获取时间格式
*
* @param format 时间格式
* @return
*/
private final static DateTimeFormatter getDateTimeFormatter(String format) {
return DateTimeFormatter.ofPattern(format);
}
}
Loading