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

JOption Yes_No Option additional
Big O of a for loop with a false condition
Printing out images from arrays
NegativeArraySizeException : obsolete compile time literal [duplicate]
Pool JVM memory across multiple machines [closed]
linux - $JAVA_HOME
JTextField set text output wrong
How to share site link to facebook in aem?
Run schedule in new thread
Swing JFrame, JDialog position with strange padding
Passing Object Parameter To Main Function Java
Exit Method then re enter (at the same point)? JAVA
Creating Web Service Proxy in JDeveloper
My app crashes while requesting permission
Android Realm get Not inside a transaction Error
Having absolute path in Manifest.mf Class-Path [duplicate]

Categories

HOME
server
ngrx
view
relayjs
q
serverspec
adfs
windows-10-universal
fancybox-3
offline
commonmark
hex-editors
circuit
nhibernate-envers
shared-hosting
amazonsellercentral
autocad-plugin
intentfilter
dcevm
mustache.php
chromium-embedded
pass-by-reference
realex-payments-api
captiveportal
one-to-many
windows-server-2000
webkitspeechrecognition
gsoap
madlib
galsim
asset-pipeline
y86
google-api-nodejs-client
qwerty
occlusion
webix-treetable
splice
cookiecutter-django
g-code
password-encryption
sage-one
mu
nativeapplication
slickedit
hittest
blacklist
chord-diagram
url-pattern
static-ip-address
android-fonts
libpng
trash
transmitfile
moveit
ready-api
apachebench
netmq
kendonumerictextbox
thredds
pundit
cakephp-3.1
bridge.net
kineticjs
system.reflection
fscommand
oxwall
pick
phalanger
marmalade
resty-gwt
app42
.aspxauth
listings
bulkloader
buster.js
jquery-knob
quickdialog
nsnetservice
funscript
armcc
asyncfileupload
joyent
sql-server-profiler
xfbml
lang
gamma
routedevent
dbal
nsviewanimation
database-management
compiler-specific
anti-piracy
sustainable-pace
project-hosting
procedural-music

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