This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- DateUtil 생성 yyyyMMddHHmm 형태 문자열 반환, 확인 메서드 - FileOutputStream, FileChannel 사용시 try-with-resource 적용
- Loading branch information
Showing
2 changed files
with
46 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.market.server.utils; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.text.ParseException; | ||
|
||
public class DateUtil { | ||
|
||
/** | ||
* 파일 처리 시간을 yyyyMMddHHmm 형태로 반환 한다. | ||
* | ||
* @param fileType 파일 타입 jpg, png | ||
* @return 처리 시간의 문자열 202009040159.jpg | ||
* @author topojs8 | ||
*/ | ||
public static String getNowTimeToyyyyMMddHHmm(Date date, String fileType) { | ||
return new SimpleDateFormat("yyyyMMddHHmm").format(date) + fileType; | ||
} | ||
|
||
/** | ||
* 파일 처리 문자열 yyyyMMddHHmm 형태 인지 확인 한다. | ||
* | ||
* @param date 처리 시간 문자열 | ||
* @return void | ||
* @author topojs8 | ||
*/ | ||
private static void parseDate(String dateStr) { | ||
try { | ||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmm"); | ||
Date date = simpleDateFormat.parse(dateStr); | ||
System.out.println("Successfully Parsed Date " + date); | ||
} catch (ParseException e) { | ||
System.out.println("ParseError " + e.getMessage()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |