formatter

Coverting String to LocalTime with/without nanoOfSeconds

时间秒杀一切 提交于 2020-01-02 01:06:06
问题 I need to convert a string to LocalTime (java-8 not joda) that may or maynot have nanoOfSeconds in the string. The String format is in the form of 07:06:05 or 07:06:05.123456 The string may or may not have a decimal place in the seconds and when it does there could be any number of characters to represent the Nano Seconds part. Using a DateTimeForamtter such as DateTimeFormatter dtf = DateTimeFormatter.ofPattern("H:mm:ss"); or DateTimeFormatter dtf = DateTimeFormatter.ofPattern("H:mm:ss

Kotlin Android / Java String DateTime Format, API21

谁说我不能喝 提交于 2019-12-30 18:43:27
问题 I want convert string datetime to formatted string. e.g "2018-12-14T09:55:00" to "14.12.2018 09:55" as String => Textview.text how can I do this with kotlin or java for android ? 回答1: Parse it to LocalDateTime then format it: LocalDateTime localDateTime = LocalDateTime.parse("2018-12-14T09:55:00"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm"); String output = formatter.format(localDateTime); If this does not work with api21, you can use: SimpleDateFormat

Kotlin Android / Java String DateTime Format, API21

ぃ、小莉子 提交于 2019-12-30 18:43:12
问题 I want convert string datetime to formatted string. e.g "2018-12-14T09:55:00" to "14.12.2018 09:55" as String => Textview.text how can I do this with kotlin or java for android ? 回答1: Parse it to LocalDateTime then format it: LocalDateTime localDateTime = LocalDateTime.parse("2018-12-14T09:55:00"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm"); String output = formatter.format(localDateTime); If this does not work with api21, you can use: SimpleDateFormat

Numeric TextField for Integers in JavaFX 8 with TextFormatter and/or UnaryOperator

帅比萌擦擦* 提交于 2019-12-27 17:40:48
问题 I am trying to create a numeric TextField for Integers by using the TextFormatter of JavaFX 8. Solution with UnaryOperator: UnaryOperator<Change> integerFilter = change -> { String input = change.getText(); if (input.matches("[0-9]*")) { return change; } return null; }; myNumericField.setTextFormatter(new TextFormatter<String>(integerFilter)); Solution with IntegerStringConverter: myNumericField.setTextFormatter(new TextFormatter<>(new IntegerStringConverter())); Both solutions have their own

How to allow null date in Spring 3 MVC

故事扮演 提交于 2019-12-25 05:09:13
问题 I've defined a global formatter for date bindings: <annotation-driven conversion-service="conversionService" /> <beans:bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"> <beans:property name="converters"> <beans:list> ... </beans:list> </beans:property> <beans:property name="formatters"> <beans:set> <beans:bean id="dateFormatter" class="org.springframework.format.datetime.DateFormatter"> <beans:constructor-arg><beans:value>dd/MM/yyyy

ASP.NET Web API deep model binding

拥有回忆 提交于 2019-12-25 04:22:39
问题 I've noticed (even in Web API 2.1) that deep parameter types get filled (processed by the model binder) only on the first level. That is : public class Person { public string Name { get; set; } public PersonDetails Details { get; set; } } public class PersonDetails { public string Address { get; set; } public int Age { get; set; } } // ... public class PersonController : ApiController { [HttpPost] public void ProcessPerson(Person person) { // person.Name is filled in correctly // person

ASP.NET Web API deep model binding

回眸只為那壹抹淺笑 提交于 2019-12-25 04:22:04
问题 I've noticed (even in Web API 2.1) that deep parameter types get filled (processed by the model binder) only on the first level. That is : public class Person { public string Name { get; set; } public PersonDetails Details { get; set; } } public class PersonDetails { public string Address { get; set; } public int Age { get; set; } } // ... public class PersonController : ApiController { [HttpPost] public void ProcessPerson(Person person) { // person.Name is filled in correctly // person

Highcharts: Returning N/A value instead of 0% in data label

こ雲淡風輕ζ 提交于 2019-12-25 02:07:14
问题 I'd like to have the y-axis data labels return 'N/A' for null values. Currently nothing is displayed. I tried using the y-formatter function to say if the y value equaled null, return N/A but haven't had luck for some reason? I'm somewhat new to Highcharts, so please forgive the basic nature of the question. formatter: function() { if (this.y !== null) return 'test'; var chart = this.series.chart; chart.renderer.text('n/a', this.point.plotX - 10, chart.plotHeight - 10).add(this.series.group)

Java Formatter not allowing new line character?

人走茶凉 提交于 2019-12-24 11:01:08
问题 So, I've got the following code to write to a file: Formatter output = ....... // Creating the formatter works, writes to appropriate file. output.format("%d\n", records.length); for(GradeRecord gR:records) { output.format(gR.toString() + "\n"); } Only problem is, the output doesn't have newline characters. Doesn't work if I replace "\n" with "\r", either. ...I don't know why this doesn't work. Output is created and writes correctly. (I see the file created and everything is written in it,

Java Formatter output

本秂侑毒 提交于 2019-12-24 05:25:07
问题 Is it true that the Formatter only writes out when you close the stream? Code: public void save(String content, String filename) { if(filename!=""){ setFileName(filename); try { output = new Formatter(new File(fileName)); output.format("%s",content); } catch (FormatterClosedException ex){ System.err.println("Error writing to file"); return; } catch ( NoSuchElementException ex){ System.err.println("invalid input"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e