Last active
February 22, 2019 04:38
-
-
Save jackblack369/d023a30c3e4007a320dd540a3a512087 to your computer and use it in GitHub Desktop.
[code-time] #java snippet
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
//date format | |
import org.apache.commons.lang3.time.DateFormatUtils; | |
String timeStr = DateFormatUtils.format(dateDate,"yyyy-MM-dd HH:mm:ss"); | |
Date dateTime = DateUtils.parseDate(dateTimeStr,"yyyy-MM-dd HH:mm:ss"); | |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
Date dateWithoutTime = sdf.parse(sdf.format(new Date())); | |
//capitalize the first letter of word | |
String output = input.substring(0, 1).toUpperCase() + input.substring(1); | |
//measure the time cost | |
long start = System.nanoTime(); | |
//... | |
long end = System.nanoTime(); | |
long used = end-start; | |
System.out.println("used:"+TimeUnit.NANOSECONDS.toMillis(used)+" ms"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment