如何转换LocalDateTime到java.sql.Date在Java的8?
我的网上搜索大多是给我Timestamp相关的代码或LocalDate到java.sql.Date.我在寻找LocalDateTime到java.sql.Date.
我有一个ComboBox,列出了设置的值.我使用setEditable(true)方法使其可编辑,但如何获取用户输入的值?我尝试了getSelectionModel().getSelectedItem()和getValue()方法,但没有成功.
这是代码.
public class Comparator extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("ComboBoxSample");
Scene scene = new Scene(new Group(), 450, 250);
ComboBox<String> emailComboBox = new ComboBox<>();
emailComboBox.getItems().addAll("A","B","C","D","E");
emailComboBox.setEditable(true);
Button b = new Button("get text");
GridPane grid = new GridPane();
grid.setVgap(4);
grid.setHgap(10);
grid.setPadding(new Insets(5, 5, 5, 5));
Label to = new Label("To: ");
Label selected = new Label();
grid.add(to, 0, 0);
grid.add(emailComboBox, 1, 0);
grid.add(b, 2, 0);
grid.add(selected, 3, 0);
b.setOnAction(e -> {
selected.setText(emailComboBox.????);
});
Group root = (Group) …Run Code Online (Sandbox Code Playgroud) 技术:
错误:
nested exception is org.springframework.dao.DataIntegrityViolationException: **could not execute statement; SQL [n/a]; constraint [null];**
java.sql.SQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`emr`.`user_detail`, CONSTRAINT `user_detail_ibfk_1` FOREIGN KEY (`id`) REFERENCES `facility` (`id`))
Run Code Online (Sandbox Code Playgroud)
DDL:
nested exception is org.springframework.dao.DataIntegrityViolationException: **could not execute statement; SQL [n/a]; constraint [null];**
java.sql.SQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`emr`.`user_detail`, CONSTRAINT `user_detail_ibfk_1` FOREIGN KEY (`id`) REFERENCES `facility` (`id`))
Run Code Online (Sandbox Code Playgroud)
Java类:
create table …Run Code Online (Sandbox Code Playgroud) 我有一个案例如下:
RowDataSet rdsHavingMaxNumericValue = dataList.stream()
.filter(r -> r.getLong(NUMERIC_VALUE) != null)
.max((r1, r2) -> r1.getId().compareTo(r2.getId()))
.get();
Run Code Online (Sandbox Code Playgroud)
我有两种情况需要根据情况找到最小值或最大值?如何用函数替换第三行的调用max,以便它直接使用.apply()方法并执行操作?
我成功分配了Collection.max或Collection min,如下所示:
BiFunction<List<RowDataSet>, Comparator<RowDataSet>, RowDataSet> mrOrlrOperation = expComponents[0] == 'M' ? Collections::max : Collections::min;
Run Code Online (Sandbox Code Playgroud)
我用它如下:
RowDataSet rds = mrOrlrOperation.apply(dataList, <some comparator>);
Run Code Online (Sandbox Code Playgroud) 同时测试当提交多个作业并发运行或稍后提交较小作业时 spark 作业的行为。我在 spark ui 中遇到了两个设置。一种是可使用 spark 的调度模式,如下图所示
我想了解两种设置和抢占之间的区别。我的要求是,在运行更大的作业时,中间提交的小作业必须获得资源而无需等待更长的时间。
我有如下方法
private Map<String,List<String>> createTableColumnListMap(List<Map<String,String>> nqColumnMapList){
Map<String, List<String>> targetTableColumnListMap =
nqColumnMapList.stream()
.flatMap(m -> m.entrySet().stream())
.collect(groupingBy(Map.Entry::getKey, mapping(Map.Entry::getValue, toList())));
return targetTableColumnListMap;
}
Run Code Online (Sandbox Code Playgroud)
我想大写地图键,但找不到一种方法。有没有Java 8的方法来实现这一目标?
我有一个Java方法如下:
private static boolean isDateBetweenRange(DataSet obj, MyClass dataSource, ConditionContext context) {
FilterContext fc = dataSource.getData();
LocalDate dateFieldToCheck = obj.getDate(fc.getDateField()).toInstant()
.atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate minDate = fc.getMinDateValue();
LocalDate maxDate = fc.getMaxDateValue();
if (minDate == null || maxDate == null) {
minDate = context.getStartDate().toInstant().atZone(ZoneId.systemDefault())
.toLocalDate();
maxDate = context.getEndDate().toInstant().atZone(ZoneId.systemDefault())
.toLocalDate();
}
boolean result = (dateFieldToCheck.isAfter(minDate) || dateFieldToCheck.isEqual(minDate))
&& (dateFieldToCheck.isBefore(maxDate) || dateFieldToCheck.isEqual(maxDate));
return result;
}
Run Code Online (Sandbox Code Playgroud)
我也想做同样的逻辑LocalDateTime.LocalDateTime如果我重载方法,它将是完全相同的代码.
如何使该方法通用,LocalDate并LocalDateTime使用泛型或任何其他机制?
我如何根据我的类型制作context.getXXXDate()... toLocalDate()或toLocalDateTime()使用通用代码?
我有一个Map流我怎么能得到具有Map值的Set?
我在这里部分地做了什么
Set<String> jcfTargetTables = measure.getConditionMap().values()
.stream()
.map(Condition::getJoinConditionFilter)
.filter(jcf -> jcf!=null)
.map(JoinConditionFilter::getTableMapping);
Run Code Online (Sandbox Code Playgroud)
最后一行给了我一个Stream<Map<String,String>>,我如何继续获取Set是Map的值?
java-8 ×5
java ×4
java-stream ×3
java-time ×2
apache-spark ×1
combobox ×1
hadoop ×1
hashmap ×1
hibernate ×1
javafx ×1
jsr310 ×1
polymorphism ×1
queue ×1