DateTime dt = new DateTime("2014-09-15T21:20:14");
System.out.println(dt);
System.out.println(dt.plusMillis(581042272).toDateTime().toLocalDateTime().toDateTime(DateTimeZone.forID("GMT")));
Run Code Online (Sandbox Code Playgroud)
dt中的时间是UTC,我想将时间设置为dt加上毫秒到GMT?但是,时间仍然打印为UTC(格林威治标准时间晚1小时).我如何设置它以便在前面一个小时?
2014-09-15T21:20:14.000+01:00
2014-09-22T14:44:16.272Z
Run Code Online (Sandbox Code Playgroud)
我知道时间正好落后一小时,因为我在格林威治标准时间15:44:16提出了这个请求
我希望程序检查当前时间是否在午夜,然后做一些事情.
我试过这个:
if (DateTime.now() == DateTime.now().withTimeAtStartOfDay()) {
//do stuff
}
Run Code Online (Sandbox Code Playgroud)
问题在于,大多数情况下,此函数所处的方法可能在午夜完全发生时不会被调用.有没有办法检查第二天是否发生或类似?
我正在尝试使用if语句为二进制文件(而log4j不执行二进制文件)执行每日文件翻转.
sitting(mary, james).
sitting(rosie, andrew).
sitting(kiera, tom).
issitting(X, Y) :- sitting(X, Y).
Run Code Online (Sandbox Code Playgroud)
嘿伙计们,我基本上想检查一下谁坐在谁旁边的真假价值,
当我输入编译器时
issitting(rosie, andrew).
Run Code Online (Sandbox Code Playgroud)
但是,当我输入时,会返回一个真值
issitting(andrew, rosie).
Run Code Online (Sandbox Code Playgroud)
返回一个假值(这应该是真的,因为它们彼此相邻).如果用户检查谁坐在彼此旁边(所有可能的组合),我不想添加三行额外的代码.
你将如何改变规则以使Prolog理解如果用户切换名称,它们仍然是真的(不是假的).
我不明白为什么它给我"假".
我被卡住了,这是迄今为止我能做到的最好:/
谢谢.
在build.gradle中
dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
}
Run Code Online (Sandbox Code Playgroud)
码
import com.myapp.LVActivity;
import org.junit.Test;
import static org.junit.Assert.*;
public class DeviceUnitTest {
@Test
public void check_that_is_correct_device_name_isTrue() {
assertThat(LVActivity.isCorrectDevice("MySpecialDevice"), is(true));
}
}
Run Code Online (Sandbox Code Playgroud)
在LVActivity:
private final static String correctName = "MySpecialDevice";
public static boolean isCorrectDevice(String deviceName) {
return deviceName.equals(correctName);
}
Run Code Online (Sandbox Code Playgroud)
错误在这里:
is(true)
Run Code Online (Sandbox Code Playgroud)
错误:
Cannot resolve method is(boolean)
Run Code Online (Sandbox Code Playgroud)
我正在尝试进行简单的本地单元测试.
我正在关注本教程http://developer.android.com/training/testing/unit-testing/local-unit-tests.html
我有两个 Docker 容器在运行。一个是 MongoDB,一个是运行一个简单的 rest API 的容器,它应该能够查询 MongoDB 容器。
端口映射
用于 MongoDB 映像的命令
docker run -p 28001:27017 -v /home/ubuntu/docker/mongodb/mongod.conf:/etc/mongod.conf --name mongodb_container -d mongodb_image
Run Code Online (Sandbox Code Playgroud)
我覆盖 mongo.conf 添加 0.0.0.0 来绑定 IP
net:
port: 27017
bindIp: [127.0.0.1,0.0.0.0]
Run Code Online (Sandbox Code Playgroud)
运行用于 API 的命令:
docker container run -it -v /home/ubuntu/docker/node_modules:/usr/lib/node_modules -p 3000:3000 --name rest_container rest_image /bin/bash
Run Code Online (Sandbox Code Playgroud)
我可以查询其余的 api,但它挂起并超时(从不返回结果)。其余配置文件如下所示:
{ "db": {
'port': 28001,
'host': "192.168.123.191"
},
'server': {
'port': 3000,
'timeout': 120,
'address': "0.0.0.0"
},
'flavor': "regular",
'debug': true
};
Run Code Online (Sandbox Code Playgroud)
其余api容器的内部IP:
172.17.0.4
mongodb容器内部IP: …
目前使用这个脚本来监控:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/mon-scripts.html
当脚本第一次运行时,我们收到了电子邮件,但此后电子邮件再也没有发送过(即使阈值不断被突破)。
假设我有Scanner方法,之后我想打印用户输入.
以此代码为例:
String randomWords;
Scanner kb = new Scanner(System.in);
System.out.print("Please enter two words separated: ");
randomWords = kb.next();
System.out.println(randomWords);
Run Code Online (Sandbox Code Playgroud)
如果输入的两个单独的单词是
hello world
Run Code Online (Sandbox Code Playgroud)
只要
hello
Run Code Online (Sandbox Code Playgroud)
打印出来
为什么是这样?如何打印包含空格的两个单词?
谢谢.
假设我有扫描仪,用户会向该扫描仪添加两个单词.
在第一个单词之前应该没有空格.
两个单词之间只有一个空格.
第二个词之后没有空格.
即
'hello world' is correct
Run Code Online (Sandbox Code Playgroud)
但
'hello world bye'
' hello world'
'hello word '
'hello world'
Run Code Online (Sandbox Code Playgroud)
都不正确.
我试过使用正则表达式,但没有成功.
编辑:只允许字母a到z(大写和小写)
public class Input extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText mEditText1 = (EditText)findViewById(R.id.number1i);
String val1 = mEditText1.getText().toString();
EditText mEditText2 = (EditText)findViewById(R.id.number2i);
String val2 = mEditText2.getText().toString();
double dVal1 = Double.parseDouble(val1);
double dVal2 = Double.parseDouble(val2);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background">
<EditText
android:id="@+id/number1i"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter your first value"
android:inputType="numberDecimal" />
<EditText
android:id="@+id/number2i"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter your second value"
android:inputType="numberDecimal" />
<TextView
android:id="@+id/output"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="22sp" />
<Button …Run Code Online (Sandbox Code Playgroud) 我有这个对象格式
{
first_name : "Bob",
last_name : "Smith",
addresses : [
{address:"1 Baker Street",
city: "london"
},
{address:"2 Baker Street",
city: "london"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想在选择下拉菜单中设置地址位,即“1 Baker Street”、“2 Baker Street”,
这是我的代码
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<select ng-model="selectedAddress" ng-options="item for item in testObject">
</select>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.testObject = {
first_name : "Bob",
last_name : "Smith",
addresses : [
{address:"1 Baker Street",
city: "london"
},
{address:"2 Baker Street",
city: …Run Code Online (Sandbox Code Playgroud)