如果我们在14:05离开法兰克福,并在16:40到达洛杉矶.飞多长时间?
我试过以下:
ZoneId frank = ZoneId.of("Europe/Berlin");
ZoneId los = ZoneId.of("America/Los_Angeles");
LocalDateTime dateTime = LocalDateTime.of(2015, 02, 20, 14, 05);
LocalDateTime dateTime2 = LocalDateTime.of(2015, 02, 20, 16, 40);
ZonedDateTime berlinDateTime = ZonedDateTime.of(dateTime, frank);
ZonedDateTime losDateTime2 = ZonedDateTime.of(dateTime2, los);
int offsetInSeconds = berlinDateTime.getOffset().getTotalSeconds();
int offsetInSeconds2 = losDateTime2.getOffset().getTotalSeconds();
Duration duration = Duration.ofSeconds(offsetInSeconds - offsetInSeconds2);
System.out.println(duration);
Run Code Online (Sandbox Code Playgroud)
但我无法得到大约11小时30分钟的成功答案.有人请帮助我弄清楚上面的问题.谢谢 :)
让我们假设我有一个员工列表:
private static List<Employee> list = new ArrayList<Employee>();
static {
list.add(new Employee("Joe", 100000, 1980));
list.add(new Employee("Tim", 50000, 1982));
list.add(new Employee("Mike", 90000, 1970));
list.add(new Employee("Rick", 50000, 1955));
list.add(new Employee("Andy", 60000, 1966));
list.add(new Employee("Tim", 10000, 1995));
list.add(new Employee("Tony", 130000, 1991));
list.add(new Employee("Timmy", 150000, 1988));
list.add(new Employee("Rich", 50000, 1980));
list.add(new Employee("Andrew", 160000, 1970));
list.add(new Employee("Ton", 150000, 1958));
list.add(new Employee("Jose", 40000, 1970));
list.add(new Employee("Timothy", 50000, 1996));
list.add(new Employee("Ricardo", 50000, 1988));
list.add(new Employee("Gemasio", 60000, 1971));
list.add(new Employee("Mike", 80000, 1992));
}
Run Code Online (Sandbox Code Playgroud)
现在我想要的是生成一些列表,它执行一些过滤,例如:salary> x和salary <y并根据员工姓名排序,然后再次排序,如果多个员工有相同的名字但工资不同但现在使用他们的工资
到目前为止我所做的是:
System.out.println( …Run Code Online (Sandbox Code Playgroud) 问题是将整数数组中的一个簇定义为具有相同值的最大元素序列.例如,阵列中{3, 3, 3, 4, 4, 3, 2, 2, 2, 2, 4}有5个簇,{3, 3, 3},{4, 4},{3},{2, 2, 2, 2}和{4}.阵列的群集压缩会使用群集中重复的数字替换每个群集.因此,前一个数组的集群压缩将是{3, 4, 3, 2, 4}.第一个集群{3, 3, 3}由单个3替换,依此类推.
public static void main(String[] args) {
int[] givenArray = {1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1};
System.out.println("Clustered Array = " + Arrays.toString(isTrivalent(givenArray)));
}
public static int[] isTrivalent (int[] a){
List<Integer> cluster = new ArrayList<Integer>();
for …Run Code Online (Sandbox Code Playgroud)