我正在处理与此处提出的问题非常类似的事情 - 比较Joda-Time时区,但它似乎对我不起作用.
这是我正在测试Joda-Time DateTime的一段代码-
DateTime estDT = new DateTime(DateTimeZone.forID("America/Puerto_Rico")).withMillisOfSecond(0);
DateTime londonDT = new DateTime(DateTimeZone.forID("Europe/London")).withMillisOfSecond(0);
System.out.println("Comparison " + londonDT.isBefore(estDT));
System.out.println("Comparison " + londonDT.isAfter(estDT));
Run Code Online (Sandbox Code Playgroud)
有趣的是,我从上面的两个sysout语句中得到'false'.任何人都可以解释一下这种比较的正确方法是什么?
我使用jdbi inTransaction()函数执行sql查询作为事务.我想知道内部如何/什么类型的锁定机制.另外,整个表是在交易期间锁定还是只是需要更新的记录?
下面是我的代码片段:
class A {
private boolean debug = false;
// Called when server boots up.
public void init (property) {
debug = property.getBoolean ("debug_var"); // read debug from a config file.
}
// some other function
public void foo () {
if (debug) {
System.out.println ("From inside the debug block");
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行代码时, if (debug) 实际上打印出“从内部调试块”如果 debug == true 在配置文件中。
两个问题:
那么,在这种情况下,编译器是否仅仅因为变量 debug 的值可能在运行时更改而在 .class 文件中包含 if 块?
如果这是真的,那么如何在某些环境中避免将某些代码添加到 .class 文件中?