LocalDate 工具类

package com.eastrobot.robotdev.utils;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class DateUtils {

DateTimeFormatter yearPattern = DateTimeFormatter.ofPattern("yyyy年MM月dd日");

DateTimeFormatter timePattern = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");

//1.String 转换成 LocalDate
public LocalDate stringTolocalDate(String date){
return LocalDate.parse(date);
}

/**
* String --> String
* 2019-12-20 转换成2019年12月20日
* @param date
* @return
* @date 2019年12月24日上午11:08:10
*/
public String stringToLocalDateTime(String date){
return LocalDate.parse(date).format(yearPattern);
}

}

posted @ 2019-12-24 11:15  硝烟漫过十八岁  阅读(542)  评论(0编辑  收藏  举报