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

Storing string with unknown character
Spring and OAuth2 in non-interactive mode, with client_credentials grant type
Eclipse .project missing
how to get the result of query inside <sql:query> using jsp
Avoiding != null using a method in java
ViewFlipper - error while tapping image
Java: method from another class can't be resolved
Java-simple-serial-connector trows exception UnsatisfiedLinkError
Looping new objects in Java and passing values from getMethods?
Can't get Jframe to close when user hits (X)
How can get the maximum value of a sensor?
How to make an HTTP authenticated service call with Olingo (Odata)
java.net.UnknownHostException: Unable to resolve host "#MYIPADDRESS, when using android + mongodb
How to remove values of a table? (MVN, Spring, Java)
Getting sql connection via EclipseLink
How to know exact the line and description of error which is occurred when executing BeanShell program in jMeter

Categories

HOME
maven
bluetooth
amazon-ec2
isabelle
tinymce
relay
jsp-tags
rsync
in-app-purchase
slick-slider
cloudkit
kibana-4
reveal.js
dax
quickbooks
invantive-sql
database-replication
django-cms
jtextfield
grails3
ml
physics-engine
tapestry
kvc
chromium-embedded
kudan
zurb-foundation-6
hammerspoon
opennlp
xpages-ssjs
fish
rst2pdf
greendao
web-api-testing
replaceall
msys2
directx-10
bcd
phonegap
functor
semantic-versioning
caret
framemaker
avcapturesession
accelerate-framework
android-kernel
gammu
dartium
ssjs
sqlite2
streamreader
azure-ml
pdf-reactor
gulp-sourcemaps
janrain
botbuilder
isbn
sencha-touch-2.3
websphere-mq-fte
scrollable
pebble-watch
fancybox-2
firmata
multi-level
fody
login-control
asp.net-4.5
clang-static-analyzer
markojs
mutation-observers
atk4
content-length
quicklisp
dukescript
sniffer
jsapi
device-orientation
internet-connection
article
xceed-datagrid
centos5
geos
spring-io
seed
eventlistener
enterprisedb
cassini-dev
uiviewanimation-curve
osql
jquery-ui-layout
subscript
qt-jambi
deobfuscation
django-tagging
celltable
lpeg
site.master
suppress
adrotator
ctp4
mtj
pascal-fc
spec#
private-members
mdac
rtml
caching-application-block

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile