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

How to print in jasper directly
Removing an element from Stack
How to declare appcompat_v7 dependency in build.gradle within eclipse project setup?
string should be drawn - no erros, using vector
How to populate a JLabel with blobs from MySQL tables
Dynamically load different XML files to Hive tables
How can I check that a user enters a date correctly? [duplicate]
Why the java code for inpainting when used in android gives error in calculate gradient method
In Java, why does ((A)b).disp() call derived class method disp() instead of base class method disp() ?
how to stop a infinite while loop when push a button [closed]
JTAPI Getting all the events of all calls
Can not insert a hexed string into int array
javax.persistence.PersistenceException: Unable to build entity manager factory org.hibernate.engine.jndi.JndiException: Unable to lookup JNDI name
Store a string with quotes (") in JAVA [duplicate]
How does Hibernate work with #OneToOne and Cascade.ALL? (using Spring)
Java - inheritance, class with methods

Categories

HOME
ibm-bluemix
image
isabelle
fluentd
heroku
dictionary
json.net
youtube-dl
rsyslog
bookshelf.js
programming-languages
jxls
fingerprint
django-imagekit
constraint-programming
metatrader4
google-cloud-spanner
moonmail
windows-phone-7
windows-server-2012
iron-router
decomposition
reactive-cocoa
undefined
excel-vba-mac
google-pagespeed
visual-composer
kryo
scriptcs
tokenize
java-7
dynamic-featured-image
newline
gsoap
exuberant-ctags
azure-sql-database
web-mining
starteam
unspecified
trim
optix
avro4s
gzipstream
heightmap
websphere-mq-fte
azure-application-gateway
sage-one
powercli
yii2-extension
knpmenubundle
flutterwave
dwscript
cubes
wdf
angular-cache
probability-density
url-masking
react-native-listview
hover-over
ptrace
coveralls
kcachegrind
varargs
sniffer
key-management
proj4js
apache-commons-net
c++03
dia
socketexception
project-planning
ceil
heisenbug
sgen
elliptic-curve
message-driven-bean
typo3-neos
mbr
pyhdf
mysqltuner
pushbackinputstream
specification-pattern
itmstransporter
libstdc++
word-processor
armcc
jspinclude
osql
window-management
gdlib
paster
adrotator
virtual-functions
aquaticprime

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile