Get current date in YYYY-MM-DD format in Java (Android) [duplicate]
This question already has an answer here: Month issue in SimpleDateFormat class 5 answers I am trying to get a Date object in the format YYYY-MM-DD representing the current system date. Below is my attempt: Date todayDate = Calendar.getInstance().getTime(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-mm-dd"); String todayString = formatter.format(todayDate); The values are as follows: todayDate: Mon May 15 16:24:47 GMT+01:00 2017 todayString: 2017-24-15 Having tried this a couple of times I noticed the todayString is not made up of YYYY-MM-DD but YYYY-[minutes][minutes]-DD. How might I get the current date in the YYYY-MM-DD format?
Change this: SimpleDateFormat formatter = new SimpleDateFormat("yyyy-mm-dd"); to this: SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); mm stands for the minutes, while MM (capitalized) stands for the month
JUnit failing from HeadlessException in program using java.awt/javax.swing
How to get name of subclass from an instance of the superclass placed in another class? [duplicate]
getcontentpane method in JFrame class
How testNG report is working internally when we implemented multi thread in class level?
Dynamically reference bundles for integration test with Pax Exam
Resource File Path as String (not streaming)
How to receive a file from a socket and not its content?
How does a developer interact with a 3D designer?
My app crashes when my phone's language is set to Persian or Arabic because of Double.parseDouble
Java 8 lambda adding to a list in a Hashmap, in a Hashmap
Time Service is not working.On Running it shows “Unfortunately Stopped”
JSON array and make it show on Android app
Switch on Enum does not import class
Why is #DiscriminatorColumn ignored when using #JoinTable?
How to retrieve the value of a text box and use it in the same page without redirecting to a next page in JSP?
Mastermind Game Algorithm