Skip to content

Instantly share code, notes, and snippets.

@srigalamilitan
Created February 14, 2016 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srigalamilitan/f3f45e2f4a21be8dba67 to your computer and use it in GitHub Desktop.
Save srigalamilitan/f3f45e2f4a21be8dba67 to your computer and use it in GitHub Desktop.
Fast Date Format www.putracode.com
package com.putracode.time;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.time.FastDateFormat;
import java.util.Date;
import static com.putracode.Util.*;
/**
* Created by KrisnaPutra on 2/14/2016.
*/
public class Learn_FastDateFormat {
//FastDateParser is Save for MultiThreading
//so you can make FastDateParser for Static variable
public static FastDateFormat DATE_FORMAT=FastDateFormat.getInstance("dd-MM-yyyy");
public static void main(String[] args)throws Exception{
printTitle("Learn Using FastDateFormat ");
String str_date="18-06-2015";
println("Parse String To Date : "+DATE_FORMAT.parse(str_date));
println("Format Date to String : "+DATE_FORMAT.format(new Date()));
println("Format Date from long milliseconds : "+ System.currentTimeMillis()+" -> "+DATE_FORMAT.format(System.currentTimeMillis()));
println("Gets a debugging string version of this formatter : "+DATE_FORMAT.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment