| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
There are many JavaScript libraries out there to deal with date formating, but none of them has identical behavior with Java's SimpleDateFormat. It's a problem when you would like to use the same date formating patterns between your JavaScript frontend and Java backend. My main goal with this project is implement SimpleDateFormat's functionality in JavaScript, as far as possible also have fun and learn a lot.
The list of supported patterns is not complete yet.
To read more about the patterns, please visit the offical documentation of SimpleDateFormat.
If no pattern defined in constructor it use pattern for default locale.
new SimpleDateFormat().format(new Date(2017, 4, 18)); //it prints 5/18/17 12:00 PMYou can apply a new pattern on existing date formatters.
var formatter = new SimpleDateFormat();
formatter.applyPattern("MM/dd/yy");
formatter.format(new Date(2017, 4, 18)); //it prints 05/18/17It supports both native Date and moment.js.
new SimpleDateFormat("MM/dd/yy").format(new Date(2017, 4, 13)); //it prints: 05/13/17
new SimpleDateFormat("MM/dd/yy").format(moment([2017, 4, 13])); //same outputFor more examples check out the tests in spec folder.
| Back | FazBrowse Home | New Git URL |