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

Is my activity being leaked - and is it the ActionBar that's doing it?
Cant figure out why the JUnit test case is failing
How to build an array recursively
Placing buttons under the combo box
windows xp 32-bit netbeans issues
Calling Java class/method using command line
Best Java GUI performance on Raspberry PI
Array Value assign in java array? [closed]
Parse a String to obtain id numbers [closed]
Getting ArrayIndexOutOfBoundsException and not sure why
Creating JAR files programmatically - Adding files to specific folder inside jar
JFreeChart stepped, 'staggerable', area/ line chart
How to get Session id after validating a user in Restful service?
How to get encoded data sent in form of bytes using body and convert to JSON?
Naming.lookup fails with Java WebStart
Can gateway serve as a dispatcher?

Categories

HOME
gitlab
cloud
keycloak
reflection
deezer
reserved
nullpointerexception
tizen-web-app
electronics
packages
disassembler
alpha
windows-server
fingerprint
yum
wamp
bs4
qore
medical
vifm
ssl-client-authentication
numeral.js
handsontable
windows-azure-storage
jplayer
iron-router
crystal-reports-2008
grails3
functional-testing
tar
buildbot
facet
kannel
brunch
xacml
replaceall
madlib
ioio
mapdb
lto
espeak
occlusion
fedex
elmah
node-sass
qcombobox
executenonquery
revapi
promela
hendrix
knockout-components
background-service
grails-tomcat-plugin
radtreelist
actionbardrawertoggle
php-internals
srand
wso2cloud
jqgrid-formatter
ideamart
oberon
streambase
bigbluebutton
gwidgets
c3
jscript.net
knuth
xojo
castle
elliptic-curve
rtmfp
resty-gwt
jsctypes
soundtouch
mylyn
limejs
mt
online-compilation
wse3.0
postgresql-performance
gnustep
stage
pydot
external-accessory
subgurim-maps
mongomapper
radcombobox
gin
nsviewanimation
user-friendly
iweb
sustainable-pace
geneva-server
dbisam

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