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

Getting file name of file being recieved on the server
Unsure about the best loop to use
Improve performance of reversing array
My Jsoup code extract elements within the first <td> tag of table only
In Java Windows Application using PdfBox Proguard zaps me
Consuming Spring Hateoas Restservice with RestTemplate
MASON Get Moore Neighbors
Java “no such element exception”
Trying to refer to a final ImageView does not work
Connect to tor with java - TorLib
Why won't this sorting work
First random number after setSeed in Java always similar
When override a method, say(), and then run the program I do not get what I anticipated to be printed
doClick(), and Simon: All buttons will unpress at the same time instead of individually
Java Algorithms: comparing each *thing* to every other [closed]
Whats causing this NullPointerException in AWT-EventQueue-0?

Categories

HOME
yii2
smarty
layout
amazon-ecs
binary-tree
gps
ios-charts
node-notifier
basic
maude-system
windows-10-universal
vault
u-sql
modelica
task
orchardcms
opentracing
foselasticabundle
emulator
grails3
functional-testing
trading
django-storage
facebook-access-token
fluentvalidation
windowbuilder
nat
typed.js
protovis
form-data
ghost4j
appfabric
gesture
azure-ml
cookiecutter-django
pdf-reactor
midl
acoustics
reactive-cocoa-5
long-polling
avconv
flickr-api
scrollable
jquery-nestable
paxos
veracode
feeds
lift-json
epson
gridpane
bonobo
autorest
jwplayer7
lttng
flash-cs5
nsviewcontroller
superstack
wapiti
wso2cloud
browser-bugs
android-listview
map-projections
0xdbe
service-accounts
twirl
p2
proj4js
gui-test-framework
asp.net-web-api-odata
xcode-6.2
titanium-modules
markers
html-helper
rdl
onactivityresult
openexr
has-many-through
valueconverter
picturefill
openlaszlo
terminal-services
floating-point-precision
xsockets.net
dbconnection
back-stack
spring-validator
typoscript2
mt
dice
viewswitcher
appconkit
postgresql-performance
whoosh
zpt
django-tagging
cinema-4d
rfc1123
sortable-tables
wise
asp.net-profiles
fixed-width
audio-capture
javap
zune
caching-application-block

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