java


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

Related Links

Mocking Hibernate Session
What should I write in version code and version name while updating an android app if I fogot to write it in the 1.0 version?
Strange error during db connection
How to make responsive table in Java?
Can't use an RSA_SIGN key for encryption. PGP key without uid
Writing/reading a matrix in and from a file in internal storage
Issue running official Restlet FirstSteps example
Multiple IPv4 sending HTTP requests
Add AWS SQS Permission to all Principals through SDK
Check if class has member variable?
Multi-threaded java server used for a buzzer beater?
Disable movement of a javafx alert
in intent in android app development using java language. error is getContext() could not be used
Java - Access original type of object in ArrayList
jsp:param in JSP
Scala Stream vs Java Stream Laziness Difference

Categories

HOME
sendgrid
openstack
minimum-spanning-tree
azure-data-factory
comparison
smarty
win32gui
baqend
yum
wamp
mouse
uber-api
gitpitch
node-pdfkit
offline
ups
netflix
vaadin7
foselasticabundle
reactcsstransitiongroup
firefox-webextensions
visjs
xlsxwriter
physics-engine
chromium-embedded
autosys
blazemeter
javacv
selectedindexchanged
react-css-modules
windows-error-reporting
typo3-6.2.x
saas
webkitspeechrecognition
madlib
functor
exuberant-ctags
siesta-swift
kendo-ui-grid
nssegmentedcontrol
wixsharp
retina-display
lto
gesture
libvpx
objectlistview
impersonation
opshub
avro4s
grid.mvc
powershell-dsc
firebase-admin
wso2carbon
long-polling
termination
dds
rails-routing
forever
memory-alignment
zendesk-app
blacklist
topbeat
pintos
firmata
libpng
bonobo
adxstudio-portals
file-writing
multi-level
google-web-starter-kit
nsviewcontroller
qcustomplot
testng-dataprovider
hexdump
bluemix-app-scan
apachebench
jfugue
cyclomatic-complexity
embedded-code
android-listview
apache-commons-fileupload
vstest.console.exe
fluid-dynamics
lustre
c++03
tablelayout
device-manager
google-reader
hippomocks
undefined-reference
jboss-weld
resty-gwt
cloud-connect
quantlib-swig
ms-project-server-2010
.aspxauth
google-cloud-save
easy-install
excel-2003
dataadapter
flashvars
specification-pattern
simba
isnullorempty
reddot
php-parser
nsobject
xmlspy
subviews
zend-translate
nsviewanimation
asp.net-profiles
meego
privilege
phonon
data-acquisition

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App