小编Jer*_*emi的帖子

Joda Time minusweeks()和plusweeks()一年中断2014/2015细分?

我可能在这里遗漏了一些东西,但我似乎无法在Joda Time的文档中找到解释或在任何地方找到解释.看起来Joda Time在计算几周时加入和减去从一年到下一年的周数时都会崩溃.

谁能解释为什么会发生这种情况以及如何正确地做到这一点

我从下面的代码中得到以下输出:

2015-01-08 - This is the current week
2015-01-01 - Removed one week
2014-12-25 - Removed one week
2014-12-17 - Removed one week //for some reason, program backed 8 days here
2014-12-10 - Removed one week
2014-12-17 - Added one week
2014-12-24 - Added one week
2014-12-31 - Added one week
2014-01-08 - Added one week //for some reason, program forwarded 8 days here, but it did not forward to 2015.
Run Code Online (Sandbox Code Playgroud)

原始代码

import org.joda.time.*;

public class …
Run Code Online (Sandbox Code Playgroud)

java jodatime

10
推荐指数
1
解决办法
387
查看次数

.NET Core 2.x Identity int 外键不能以 int 主键为目标

我有一个运行 .net core 2.x 的 Web 应用程序(最终刚刚从 .net core 1.x 升级),并且我已经将大部分内容从 .net core 1.x 移植到 2.x。然而,我的身份实现遇到了砖墙。它在 .net core 1.x 上运行良好,但现在它拒绝了。

该实现在 Entity Framework Core 上运行,并首先构建数据库(在预先存在的数据库中实现)。

我的问题是,当我现在尝试使用 .net core 2.x 登录时,我收到一条错误消息,指出:

InvalidOperationException:从 'AspNetUserRole.AspNetRole' 到具有外键属性 {'RoleId' : int} 的 'AspNetUserRole.AspNetRole' 的关系无法定位主键 {'Id' : int},因为它不兼容。为此关系配置一个主键或一组兼容的外键属性。

对我来说,这完全没有意义。int外键如何与int主键不兼容?

上下文和类的实际实现如下(这是一个非常简单的实现):

public partial class AspNetUser : IdentityUser<int>
{ }
public partial class AspNetRole : IdentityRole<int>
{ }
public partial class AspNetRoleClaim : IdentityRoleClaim<int>
{ }
public partial class AspNetUserClaim : IdentityUserClaim<int>
{ } …
Run Code Online (Sandbox Code Playgroud)

c# invalidoperationexception entity-framework-core asp.net-core asp.net-core-identity

7
推荐指数
1
解决办法
1万
查看次数

禁用多列选择

有什么方法可以禁用 Swing JTable 的多列选择?通过覆盖选择模型的选择间隔,我在“Tid”列中一起禁用了选择:

myTable.getColumnModel().setSelectionModel(new DefaultListSelectionModel() {
            private boolean isSelectable(int index0, int index1) {
                return index1 != 0;
            }

            @Override
            public void setSelectionInterval(int index0, int index1) {
                if(isSelectable(index0, index1)) {
                    super.setSelectionInterval(index0, index1);
                }
            }

            @Override
            public void addSelectionInterval(int index0, int index1) {
                if(isSelectable(index0, index1)) {
                    super.addSelectionInterval(index0, index1);
                }
            }
        });
Run Code Online (Sandbox Code Playgroud)

我的猜测是,还可以通过覆盖选择模型中的方法来禁止选择多列。但我真的不知道如何做到这一点。

允许选择 允许的选择 - 选择仅跨越一列但跨越多行

不允许的选择 不允许的选择 - 选择跨越多列和多行

java swing jtable

2
推荐指数
1
解决办法
2574
查看次数