java


Setting max date in calenderView to a specific date


I have the following code
CalendarView cal = (CalendarView) findViewById(R.id.calendarView);
cal.setMaxDate();
cal.setMinDate(System.currentTimeMillis() - 1000);
I'm not sure how to format a date to put in setMaxDate, it says it wants a long data type? How would I format 31/12/2016 for example?
setMaxDate expects a number of milliseconds since the epoch (see javadoc).
One way to do it would be:
SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd");
Date maxDate = sdf.parse("2016-12-31");
cal.setMaxDate(maxDate.getTime());
Or you could use a Calendar (untested but probably more efficient):
Calendar c = Calendar.getInstance();
c.clear();
c.set(2016, Calendar.DECEMBER, 31);
cal.setMaxDate(c.getTimeInMillis());

Related Links

Application Logging for elastic beanstalk
Deadbolt play java Change password the first time login
Android Issue Logging ArrayList
Best way to make multiple asynchronous calls to same web service
Count the number of audio samples between two identical tones
Unable to enable cache control in Spring Security config
where to find com.focus_sw.fieldtalk.* for the modbus example
Scala - How to Return this Kind of RDD type
get id with distinct with hibernate criteria
How to get all User Profile Claims of a user in Wso2 Identity server
Tomcat 8.5.4 websocket examples doesn't work
Junit in spring based project where multiple projects are involved
How to add an attribute to an SVG produced by Apache Batik
Non blocking reading in Scala without framing
Java asynchronous post JSON until response is okay
Java loading a resource from outside the classpath (pentaho)

Categories

HOME
java
log4j
winforms
wso2-am
hive
deployment
mediawiki
heroku
json.net
layout
sd-card
xmpp
binary-tree
survey
callback
ios-charts
slick-slider
gnupg
numeral.js
collectd
windows-phone-7
ups
systemc
undefined
oxyplot
jquery-ajaxq
intentfilter
mps
web-sql
emgucv
android-widget
javascriptcore
karaf
lxd
hybridauth
bitbucket-pipelines
swisscomdev
abstract-class
az-application-insights
janrain
eigenvalue
fakeiteasy
heightmap
apache-fop
komodoedit
zip4j
logparser
jlink
nsarray
background-service
file-writing
qpid
persist
actionbardrawertoggle
qgraphicsview
sdf
bgp
ptrace
itextpdf
ruby-2.2
qdialog
retina
libressl
python-green
zend-route
navigationservice
comexception
fmod
html4
android-screen-support
interface-orientation
lcs
specification-pattern
mercurial-server
vdsp
gcj
f#-powerpack
horizontal-accordion
mtj
premature-optimization
gacutil
data-acquisition
.net-1.0
document-conversion

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