Skip to content

Instantly share code, notes, and snippets.

@jackblack369
Last active February 22, 2019 04:38
Show Gist options
  • Save jackblack369/d023a30c3e4007a320dd540a3a512087 to your computer and use it in GitHub Desktop.
Save jackblack369/d023a30c3e4007a320dd540a3a512087 to your computer and use it in GitHub Desktop.
[code-time] #java snippet
//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