Re: Java METHOD to return date instead of Calendar field
Quote:
Originally Posted by
keang
Can't say I'd recommend doing this.
Using ONE_DAY_IN_MILLIS = 1000*60*60*24 is fine for all those days that are 24 hours long but a lot of countries use daylight saving and so each year you get one day at 23 hours and one day at 25 hours.
Yeah I understand that but I'm only needing to find out that date of previous days and its only ran once a day at around 9am, so 24 hours before will always be the correct date.
I'm giving up on this whole thing though, the applet I'm writing the script for can't use 'long' objects (only integer) so this way wont work and another way I came up with won't work because the applet is saying date.setTime and and even Calendar.setTimeMillis don't exist which has just thrown me over the edge. I'm just going to resort to asking the user for the day of the month.
Thanks for the help.
Re: Java METHOD to return date instead of Calendar field
this way wont work and another way I came up with won't work
If you'd post the error messages, maybe someone could help.
Re: Java METHOD to return date instead of Calendar field
Quote:
My specific issue is with the Calendar.DATE and Calendar.DAY_OF_MONTH because in order to get yesterdays date I would have to do something like:
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE,-1);
but the script doesn't recognize Calendar.DATE because it isn't a method.
Well why not substitute Calendar.Date for the value it represents (see here) ie:
Code:
Calendar cal = Calendar.getInstance();
cal.add(5,-1);