Java 日期和时间

发布于 2024-11-02 17:35:08 字数 599 浏览 1 评论 0原文

嘿伙计们,我想找到一些有关 java 和日历类的信息。我需要写一个 if 语句,说明如果是周末,即周六或周日,则执行此操作,否则执行此

操作干杯

,感谢您的帮助,但我认为我没有正确实现它,现在没有显示任何内容。

$(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() {
    recalculate();
 });

});

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() {
    recalculate();
 });

});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

愁以何悠 2024-11-09 17:35:08

一切都在这里:
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
}

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
}
与他有关 2024-11-09 17:35:08
if(cal.get(Calendar.DAY_OF_WEEK)== Calendar.SATURDAY ||cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
    //hurray..weekend..!
}else{

}

另请参阅

if(cal.get(Calendar.DAY_OF_WEEK)== Calendar.SATURDAY ||cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
    //hurray..weekend..!
}else{

}

See Also

眉黛浅 2024-11-09 17:35:08
Calendar cld = Calendar.getInstance();
if (cld.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
// it's saturday
}
Calendar cld = Calendar.getInstance();
if (cld.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
// it's saturday
}
拥有 2024-11-09 17:35:08

@Simone 你那里的代码看起来一点也不像Java - 事实上,它更像是JQuery 格式的JavaScript。不管怎样,@Matthew 和@Jigar 已经为您提供了示例代码。

如果这没有帮助,他们会确保下次将您的问题标记为 Javascript,以便有相关经验的人可以帮助回答您的问题。

祝你好运

@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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文