Last active
December 12, 2015 01:18
-
-
Save lseongjoo/4689833 to your computer and use it in GitHub Desktop.
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
import java.sql.Timestamp; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.Locale; | |
public class TimeUtil { | |
public static Timestamp getTimestamp(){ | |
Timestamp timestamp = new Timestamp(System.currentTimeMillis()); | |
return timestamp; | |
} | |
public static String getTimestamp(String pattern){ | |
if(pattern.isEmpty()){ | |
pattern = "yyyy-MM-dd HH:mm:ss"; | |
} | |
SimpleDateFormat dateformat = new SimpleDateFormat(pattern, Locale.KOREA); | |
Timestamp timestamp = getTimestamp(); | |
String time = dateformat.format(timestamp); | |
return time; | |
} | |
public static long getTimestamp(Timestamp timestamp){ | |
return timestamp.getTime(); | |
} | |
public static String getTimeFormat(long time){ | |
Date date = new Date(time); | |
SimpleDateFormat dateFormat = | |
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.KOREA); | |
return dateFormat.format(date); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment