Browse Source

getFormatter 更名为 getDateTimeFormatter

James 5 years ago
parent
commit
f170de7981

+ 8 - 8
src/main/java/com/jfinal/kit/TimeKit.java

@@ -48,7 +48,7 @@ public class TimeKit {
 	 */
 	 */
 	private static final Map<String, DateTimeFormatter> formaters = new SyncWriteMap<>();
 	private static final Map<String, DateTimeFormatter> formaters = new SyncWriteMap<>();
 	
 	
-	public static DateTimeFormatter getFormatter(String pattern) {
+	public static DateTimeFormatter getDateTimeFormatter(String pattern) {
 		DateTimeFormatter ret = formaters.get(pattern);
 		DateTimeFormatter ret = formaters.get(pattern);
 		if (ret == null) {
 		if (ret == null) {
 			ret = DateTimeFormatter.ofPattern(pattern);
 			ret = DateTimeFormatter.ofPattern(pattern);
@@ -77,7 +77,7 @@ public class TimeKit {
 	 * 例如:now("yyyy-MM-dd HH:mm:ss")
 	 * 例如:now("yyyy-MM-dd HH:mm:ss")
 	 */
 	 */
 	public static String now(String pattern) {
 	public static String now(String pattern) {
-		return LocalDateTime.now().format(getFormatter(pattern));
+		return LocalDateTime.now().format(getDateTimeFormatter(pattern));
 	}
 	}
 	
 	
 	/**
 	/**
@@ -85,21 +85,21 @@ public class TimeKit {
 	 * 例如:format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss")
 	 * 例如:format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss")
 	 */
 	 */
 	public static String format(LocalDateTime localDateTime, String pattern) {
 	public static String format(LocalDateTime localDateTime, String pattern) {
-		return localDateTime.format(getFormatter(pattern));
+		return localDateTime.format(getDateTimeFormatter(pattern));
 	}
 	}
 	
 	
 	/**
 	/**
 	 * LocalDate 按指定 pattern 转换成 String
 	 * LocalDate 按指定 pattern 转换成 String
 	 */
 	 */
 	public static String format(LocalDate localDate, String pattern) {
 	public static String format(LocalDate localDate, String pattern) {
-		return localDate.format(getFormatter(pattern));
+		return localDate.format(getDateTimeFormatter(pattern));
 	}
 	}
 	
 	
 	/**
 	/**
 	 * LocalTime 按指定 pattern 转换成 String
 	 * LocalTime 按指定 pattern 转换成 String
 	 */
 	 */
 	public static String format(LocalTime localTime, String pattern) {
 	public static String format(LocalTime localTime, String pattern) {
-		return localTime.format(getFormatter(pattern));
+		return localTime.format(getDateTimeFormatter(pattern));
 	}
 	}
 	
 	
 	/**
 	/**
@@ -127,21 +127,21 @@ public class TimeKit {
 	 * 按指定 pattern 将 String 转换成 LocalDateTime
 	 * 按指定 pattern 将 String 转换成 LocalDateTime
 	 */
 	 */
 	public static LocalDateTime parseLocalDateTime(String localDateTimeString, String pattern) {
 	public static LocalDateTime parseLocalDateTime(String localDateTimeString, String pattern) {
-		return LocalDateTime.parse(localDateTimeString, getFormatter(pattern));
+		return LocalDateTime.parse(localDateTimeString, getDateTimeFormatter(pattern));
 	}
 	}
 	
 	
 	/**
 	/**
 	 * 按指定 pattern 将 String 转换成 LocalDate
 	 * 按指定 pattern 将 String 转换成 LocalDate
 	 */
 	 */
 	public static LocalDate parseLocalDate(String localDateString, String pattern) {
 	public static LocalDate parseLocalDate(String localDateString, String pattern) {
-		return LocalDate.parse(localDateString, getFormatter(pattern));
+		return LocalDate.parse(localDateString, getDateTimeFormatter(pattern));
 	}
 	}
 	
 	
 	/**
 	/**
 	 * 按指定 pattern 将 String 转换成 LocalTime
 	 * 按指定 pattern 将 String 转换成 LocalTime
 	 */
 	 */
 	public static LocalTime parseLocalTime(String localTimeString, String pattern) {
 	public static LocalTime parseLocalTime(String localTimeString, String pattern) {
-		return LocalTime.parse(localTimeString, getFormatter(pattern));
+		return LocalTime.parse(localTimeString, getDateTimeFormatter(pattern));
 	}
 	}
 	
 	
 	/**
 	/**

+ 1 - 1
src/main/java/com/jfinal/template/io/Writer.java

@@ -63,7 +63,7 @@ public abstract class Writer {
 	 * 格式化输出 LocalDateTime、LocalDate、LocalTime
 	 * 格式化输出 LocalDateTime、LocalDate、LocalTime
 	 */
 	 */
 	public void write(java.time.temporal.Temporal temporal, String pattern) throws IOException {
 	public void write(java.time.temporal.Temporal temporal, String pattern) throws IOException {
-		write(com.jfinal.kit.TimeKit.getFormatter(pattern).format(temporal));
+		write(com.jfinal.kit.TimeKit.getDateTimeFormatter(pattern).format(temporal));
 	}
 	}
 }
 }