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 triangle?
Not found swagger.json from Swagger + Jersey 1 + Guice Application
Assertions on object which do not implement “equals” and “toString” [duplicate]
Spring JPA returning only fields, not entities
Android Studio Cache Invalidation [duplicate]
Delphi and java + generic
Extending Swing components to run on EDT
Java -> Can't close window while paint
Java - two threads with wait() and notify()
Java Web Start: Signed Jar without APPLICATION.JNLP launches via JNLP since 8u91
Timeline animation on Stage is not smooth
Fraction class trouble (Java)
AndEngine physicsWorld crash the game
How to shuffle an arraylist once [closed]
How do I stop previous graphics from being redrawn in Java?
Finished AP Computer Science, where should I go next? [closed]

Categories

HOME
appx
stock
fft
raspberry-pi
routes
packages
networkx
directx
maude-system
reveal.js
apache-cayenne
jsprit
pc
zapier
jasonette
tibco-mdm
format-specifiers
h2db
numerical-methods
info.plist
fifo
typo3-6.2.x
dbclient
atlassian-crucible
nat
react-chartjs
nameservers
ecto
pim
cloud-code
force-layout
sequential
suricata
occlusion
cookiecutter-django
avro4s
netcdf4
angular2-meteor
sage-one
domain-model
idisposable
statsd
brightcove
nodebb
android-cursor
hittest
specrun
google-feed-api
libpng
merge-conflict-resolution
superstack
ios4
asp.net5
tcpserver
qtableview
teamcity-8.0
ruby-2.2
fouc
interrupted-exception
key-management
truevault
jscript.net
gadt
winddk
preferences
wp-query
ccss
dexterity
ora-00911
interface-orientation
eventlistener
wsdl-2.0
referrer
dmoz
venn-diagram
pysimplesoap
ocx
buildr
hirefire
coredump
horizontal-accordion
calling-convention
web-architecture
avatar
privilege

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