formatter

Objective c string formatter for distances

醉酒当歌 提交于 2019-12-03 06:14:02
问题 I have a distance as a float and I'm looking for a way to format it nicely for human readers. Ideally, I'd like it to change from m to km as it gets bigger, and to round the number nicely. Converting to miles would be a bonus. I'm sure many people have had a need for one of these and I'm hoping that there's some code floating around somewhere. Here's how I'd like the formats: 0-100m: 47m (as a whole number) 100-1000m: 325m or 320m (round to the nearest 5 or 10 meters) 1000-10000m: 1.2km

How to stop Eclipse formatter from placing all enums on one line

你说的曾经没有我的故事 提交于 2019-12-03 02:36:04
问题 I have enums like: public static enum Command { login, register, logout, newMessage } When formatting the file, the output becomes: public static enum Command { login, register, logout, newMessage } 回答1: The answer by @wjans worked fine for normal enums, but not for enums with arguments. To expand on his answer a bit, here's the settings that provided the most sensible formatting for me in Eclipse Juno: Window > Preferences > Java > Code Style > Formatter Click Edit Select the Line Wrapping

Exception in thread “main” java.lang.NoClassDefFoundError: gherkin/formatter/Formatter

天涯浪子 提交于 2019-12-02 21:19:25
问题 I am learning how to write BDD test scripts in JAVA using Cucumber. However, I keep getting the above error and not sure why. I have the Cukes Gherkin as a dependency. POM <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>Cucumber</groupId> <artifactId

Objective c string formatter for distances

孤街醉人 提交于 2019-12-02 19:37:56
I have a distance as a float and I'm looking for a way to format it nicely for human readers. Ideally, I'd like it to change from m to km as it gets bigger, and to round the number nicely. Converting to miles would be a bonus. I'm sure many people have had a need for one of these and I'm hoping that there's some code floating around somewhere. Here's how I'd like the formats: 0-100m: 47m (as a whole number) 100-1000m: 325m or 320m (round to the nearest 5 or 10 meters) 1000-10000m: 1.2km (round to nearest with one decimal place) 10000m +: 21km If there's no code available, how can I write my

Save a formatted String to a LocalDate

六月ゝ 毕业季﹏ 提交于 2019-12-02 15:41:01
问题 I have a DateConverter class: public class DateConverter extends StringConverter<LocalDate> { String pattern = "EEE, dd. MM. uuuu"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern,Locale.US); @Override public String toString(LocalDate object) { try { return formatter.format(object); } catch(Exception ex) { return ""; } } @Override public LocalDate fromString(String string) { try { return LocalDate.parse(string, formatter); } catch(Exception ex) { return null; } } public

How to stop Eclipse formatter from placing all enums on one line

北战南征 提交于 2019-12-02 14:24:47
I have enums like: public static enum Command { login, register, logout, newMessage } When formatting the file, the output becomes: public static enum Command { login, register, logout, newMessage } PolyTekPatrick The answer by @wjans worked fine for normal enums, but not for enums with arguments. To expand on his answer a bit, here's the settings that provided the most sensible formatting for me in Eclipse Juno: Window > Preferences > Java > Code Style > Formatter Click Edit Select the Line Wrapping tab Select the enum declaration treenode Set Line wrapping policy to Wrap all elements, every

Padding a numeric display in WPF

时光总嘲笑我的痴心妄想 提交于 2019-12-02 12:16:33
问题 I've got a position readout that's very simple -- it's just a TextBlock with a Style applied to it. In that Style, I just set it like so (there are more properties than this, but I took them out for conciseness): <Style x:Key="NumberStyle" TargetType="{x:Type TextBlock}"> <Setter Property="TextAlignment" Value="Center" /> </Style> Now, I have one display that uses this style, and it will display a number from 0.0 to 30000.0. The problem is that since I'm centering the text, the number (if

Exception in thread “main” java.lang.NoClassDefFoundError: gherkin/formatter/Formatter

核能气质少年 提交于 2019-12-02 10:46:54
I am learning how to write BDD test scripts in JAVA using Cucumber. However, I keep getting the above error and not sure why. I have the Cukes Gherkin as a dependency. POM <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>Cucumber</groupId> <artifactId>Cucumber</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>info.cukes<

Save a formatted String to a LocalDate

半世苍凉 提交于 2019-12-02 07:18:32
I have a DateConverter class: public class DateConverter extends StringConverter<LocalDate> { String pattern = "EEE, dd. MM. uuuu"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern,Locale.US); @Override public String toString(LocalDate object) { try { return formatter.format(object); } catch(Exception ex) { return ""; } } @Override public LocalDate fromString(String string) { try { return LocalDate.parse(string, formatter); } catch(Exception ex) { return null; } } public String getPattern(){ return pattern; } } And I have this piece of code: allProd.forEach((prod) -> {

Padding a numeric display in WPF

主宰稳场 提交于 2019-12-02 04:07:10
I've got a position readout that's very simple -- it's just a TextBlock with a Style applied to it. In that Style, I just set it like so (there are more properties than this, but I took them out for conciseness): <Style x:Key="NumberStyle" TargetType="{x:Type TextBlock}"> <Setter Property="TextAlignment" Value="Center" /> </Style> Now, I have one display that uses this style, and it will display a number from 0.0 to 30000.0. The problem is that since I'm centering the text, the number (if changing rapidly) jumps all over the place and it's a little disturbing. I'd like to format my string so