gpt4 book ai didi

gwt - 如何在gwt中获得一年中的一周

转载 作者:行者123 更新时间:2023-12-05 01:35:59 24 4
gpt4 key购买 nike

如何在 gwt 中获取一年中的第几周?我试图获得一年中的一周,但无法获得。请指导我。我试过使用下面的代码,但它打印的是一天中的一周而不是全年。

DateTimeFormat format = DateTimeFormat.getFormat("c"); 
String dayOfWeek = format.format(new Date());
E12CommonUtils.printOnConsole("dayOfWeek ="+dayOfWeek);

最佳答案

以下将执行您的请求。

Date date = new Date(); 
Date yearStart = new Date(date.getYear(), 0, 0);

double week = (date.getTime() - yearStart.getTime())/(double)(7 * 24 * 60 * 60 * 1000);
System.out.println((int)Math.ceil(week));

关于gwt - 如何在gwt中获得一年中的一周,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31558917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com