在Java 8中,我想将日期时间从UTC转换为ACST(UTC + 9:30).
输入 - > 2014-09-14T17:00:00 + 00:00
output-> 2014-09-15 02:30:00
String isoDateTime = "2014-09-14T17:00:00+00:00";
LocalDateTime fromIsoDate = LocalDateTime.parse(isoDateTime, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
ZoneOffset offset = ZoneOffset.of("+09:30");
OffsetDateTime acst = OffsetDateTime.of(fromIsoDate, offset);
System.out.println(acst.toString()); // 2014-09-14T17:00+09:30
System.out.println(acst.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); // 2014-09-14T17:00:00+09:30
Run Code Online (Sandbox Code Playgroud)
为什么没有执行偏移?
从Eclipse Kepler(在Ubuntu 12.04上)卸载JRebel后,当我尝试在服务器上运行我的Web应用程序时,我收到以下错误:
'在localhost启动Tomcat v7.0服务器'遇到了问题.引用未定义的变量jrebel_args.
如何删除此引用?
我正在使用 Spring Boot 1.4.3.RELEASE 并希望在运行测试时从扫描中排除某些组件。
@RunWith(SpringRunner.class)
@SpringBootTest
@ComponentScan(
basePackages = {"com.foobar"},
excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {AmazonKinesisRecordChecker.class, MyAmazonCredentials.class}))
public class ApplicationTests {
@Test
public void contextLoads() {
}
}
Run Code Online (Sandbox Code Playgroud)
尽管有过滤器,当我运行测试时,不需要的组件被加载并且 Spring Boot 崩溃,因为这些类需要 AWS 环境才能正常工作:
2017-01-25 16:02:49.234 ERROR 10514 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'amazonKinesisRecordChecker' defined in file
Run Code Online (Sandbox Code Playgroud)
问题:如何使过滤器工作?
在 R 3.4.0 中,如何将 prop.table() 生成的所有百分比四舍五入到一行中的 3 个小数位?
这不起作用:
MyTable$MyCol %>% table() %>% prop.table()*100 %>% round(.,3)
-7 -2 0 1 2 3 4 5
0.4672897 0.2336449 31.7757009 1.6355140 44.3925234 20.3271028 0.4672897 0.7009346
Run Code Online (Sandbox Code Playgroud)
预期类似:
-7 -2 0 1 2 3 4 5
0.467 0.233 31.775 1.635 44.392 20.327 0.467 0.700
Run Code Online (Sandbox Code Playgroud) 在Android应用程序(min sdk 11,target sdk 18)上,扩展Fragment的类应该创建带有一个标签和一个图标的TabHost选项卡(TabSpec).但...
TabSpec ts1;
// if the label is set to "Home", the label is displayed but not the image
ts1 = tab_host.newTabSpec("TAB_ONE").setIndicator("Home", getActivity().getResources().getDrawable(R.drawable.ic_tabone)).setContent(R.id.edit_species_tab);
// if the label is null or empty, the image is displayed
ts1 = tab_host.newTabSpec("TAB_ONE").setIndicator(null, getActivity().getResources().getDrawable(R.drawable.ic_tabone)).setContent(R.id.edit_species_tab);
Run Code Online (Sandbox Code Playgroud)
据我所知,文档没有提到标签和图标是互斥的.
起初我以为标签有一个固定的背景颜色隐藏图标,但事实并非如此.事实上,当我设置TabHost背景时,我可以看到标签是透明的:
tab_host.getTabWidget().setBackgroundResource(R.drawable.ic_mybackground);
Run Code Online (Sandbox Code Playgroud)
如何设置TabSpec背景,以便为每个选项卡显示标签和图标?
tab_host.xml
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="65dp" >
<LinearLayout
android:id="@+id/edit_species_tab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
</LinearLayout>
<LinearLayout
android:id="@+id/edit_regions_tab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
</LinearLayout> …Run Code Online (Sandbox Code Playgroud) android android-layout android-tabhost android-drawable fragment-tab-host
我需要检查y是否严格是bar而不是foo的实例。我怎样才能在 Scala 中做到这一点?
trait foo {}
trait bar extends foo {}
val x = new foo {}
val y = new bar {}
x.isInstanceOf[foo] // true
x.isInstanceOf[bar] // false
y.isInstanceOf[bar] // true
y.isInstanceOf[foo] // true (but I want it to return false)
Run Code Online (Sandbox Code Playgroud) 我有一个与此类似的 Pandas 数据框:
>>> df = pd.DataFrame(data=np.array([['red', 'cup', 1.50], ['blue', 'jug', 2.40], ['red', 'cup', 1.75], ['blue', 'cup', 2.30]]),
... columns=['colour', 'item', 'price'])
>>> df
colour item price
0 red cup 1.5
1 blue jug 2.4
2 red cup 1.75
3 blue cup 2.3
Run Code Online (Sandbox Code Playgroud)
计算每种可能的颜色和商品组合的价格汇总统计的最简洁方法是什么?
预期输出例如:
colour item mean stdev
red cup 1.625 0.176
blue jug 2.4 NA
blue cup 2.3 NA
Run Code Online (Sandbox Code Playgroud) 使用 Pandas 1.0.1,给定这个演示数据框,我想用在子组“框”上计算的中值替换数字列重量和价格(不修改原始数据框):
import pandas as pd
import numpy as np
df = pd.DataFrame({'box': ['a100','a100','a100','a200','a200','a300','a300','a300','a300'], 'id_in_box': ['2x', '1x', '3x', '2x', '1x', '3x', '1x', '2x', '4x'], 'weight': [2, 1, 2, 3, 4, 2, 8, 6, 4.5], 'price': [1.5, 3.2, 2.1, 3.3, 1.5, 3.2, 2.1, 3.3, 4.4]})
df
box id_in_box weight price
0 a100 2x 2.0 1.5
1 a100 1x 1.0 3.2
2 a100 3x 2.0 2.1
3 a200 2x 3.0 3.3
4 a200 1x 4.0 1.5
5 a300 3x 2.0 3.2 …Run Code Online (Sandbox Code Playgroud) 在针对API 11到18的Android应用中,我使用字符串数组动态填充了ListView,并为每一行添加了一个侦听器.该文本通常仅涵盖行的约50%.问题是,如果我单击实际文本,则会触发onItemClick操作,但如果我单击该行的空白部分则不会.
我的问题是:如何将侦听器添加到每行的整个区域/视图中?
public class MainActivity extends ActionBarActivity {
protected void onCreate(Bundle savedInstanceState) {
...
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.activity_list_item, my_array);
ListView listview = (ListView) findViewById(R.id.listView1);
listview.setAdapter(adapter);
// add listener
listview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Log.d(TAG, "position=" + position);
}
});
Run Code Online (Sandbox Code Playgroud)
activity_main.xml中:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:id="@+id/listView1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".80"
>
</ListView>
Run Code Online (Sandbox Code Playgroud)
activity_list_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/my_textview"
android:textSize="35sp"
/>
Run Code Online (Sandbox Code Playgroud) android listview android-listview onitemclicklistener onitemclick
使用 Pandas 1.0.0,如何在一行代码中将日期时间数据帧列的时间更改为午夜?
例如:从
START_DATETIME
2017-02-13 09:13:33
2017-03-11 23:11:35
2017-03-12 00:44:32
...
Run Code Online (Sandbox Code Playgroud)
到
START_DATETIME
2017-02-13 00:00:00
2017-03-11 00:00:00
2017-03-12 00:00:00
...
Run Code Online (Sandbox Code Playgroud)
我的尝试:
df['START_DATETIME'] = df['START_DATETIME'].apply(lambda x: pd.Timestamp(x).replace(hour=0, minute=0, second=0))
Run Code Online (Sandbox Code Playgroud)
但这会产生
START_DATETIME
2017-02-13
2017-03-11
2017-03-12
...
Run Code Online (Sandbox Code Playgroud) pandas ×3
python ×3
android ×2
java ×2
eclipse ×1
instanceof ×1
java-8 ×1
jrebel ×1
listview ×1
onitemclick ×1
r ×1
rounding ×1
scala ×1
spring ×1
spring-boot ×1
spring-test ×1
statistics ×1
subclass ×1
subtyping ×1
timezone ×1