Java Date and time
Hey guys im trying to find some info regarding java and the calendar class. I need to write an if statement that says if it is a weekend i.e sat or sunday then do this else do this
Cheers
Thanks for the help however i don't think im implementing it correctly, nothing is being displayed now.
$(document).ready(function() {
function recalculate() {
var sum = 49;
int day = Calendar.getInstance().get( Calendar.DAY_OF_WEEK );
if ( day == Calendar.SATURDAY || day == Calendar.SUNDAY ){
sum = 80;
}
$("input[type=checkbox]:checked").each(function() {
sum = parseInt($(this).attr("rel"));
});
$("#output").html(sum);
}
$("input[type=checkbox]").change(function() {
recalc开发者_C百科ulate();
});
});
It's all in here: http://download.oracle.com/javase/6/docs/api/java/util/Calendar.html
int day = Calendar.getInstance().get( Calendar.DAY_OF_WEEK );
if ( day == Calendar.SATURDAY || day == Calendar.SUNDAY ){
// fun fun fun fun fun
}
if(cal.get(Calendar.DAY_OF_WEEK)== Calendar.SATURDAY ||cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
//hurray..weekend..!
}else{
}
See Also
- API Documentation
Calendar cld = Calendar.getInstance();
if (cld.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
// it's saturday
}
@Simone The code you have there does not look anything like Java - infact, it's more like JavaScript in JQuery format. Anyway, @Matthew and @Jigar have provided you with sample code.
If that does not help, them make sure to tag your question as Javascript next time so that people with that experience can help answer your question.
Good luck
精彩评论