Hello,<br>
Can someone give me a quick example of how to set the calendar to the current date. I've been searching through the docs but can't find it.<br>
<br>
Thanks,<br>
DigitalOx<br>
If I understand you,<br>
Date d=new Date()<br>
will make a new Date class to a variable d, and<br>
fills it the current date.<br>
Try System.out.println(new Date());<br>
Bye, Otto.
Hi Otto,<br>
Thanks again for helping me out again. Not only do I need the date, but I need to save it and pull it back up. In order to avoid all those deprecated date functions I did it like this: <br>
Date date = new Date();<br>
System.out.println(date);<br>
calendar.setTime(date);<br>
System.out.println(calendar.get(calendar.DAY_OF_WEEK));<br>
System.out.println(calendar.get(calendar.YEAR));<br>
<br>
Thanks<br>
DigitalOx<br>
<br>
Hi!<br>
<br>
Ok, try this:<br>
import java.util.Calendar;<br>
Calendar now=Calendar.getInstance();<br>
System.out.println(now.getTime());<br>
<br>
The getInstance() make a new object, and fills the time fields with the current time and date (local). See the getInstance() and getInstance(xxx, xxx).<br>
By, Otto.<br>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.