@Test public void testToRawTimeWithTimeZone() { when(provider.isTimeZone("America/Sao_Paulo")).thenReturn(true); final String expected = "time(\"22:30:10@America/Sao_Paulo\")"; final String input = "22:30:10 America/Sao_Paulo"; final String actual = formatter.toRaw(input); assertEquals(expected, actual); }
public String toRaw(final String input) { if (!input.contains(" ")) { return appendPrefixAndSuffix(input); } final String[] parts = input.split(" "); if (parts.length == 2) { final String secondPart = parts[1].trim(); if (timeZoneProvider.isTimeZone(secondPart)) { return appendPrefixAndSuffix(parts[0].trim() + "@" + secondPart); } else { return appendPrefixAndSuffix(parts[0].trim() + "Z"); } } final String time = parts[0].trim(); final String offSet = parts[2].trim(); return appendPrefixAndSuffix(time + offSet); }
TimeValueFormatter { public String toRaw(final String input) { if (!input.contains(" ")) { return appendPrefixAndSuffix(input); } final String[] parts = input.split(" "); if (parts.length == 2) { final String secondPart = parts[1].trim(); if (timeZoneProvider.isTimeZone(secondPart)) { return appendPrefixAndSuffix(parts[0].trim() + "@" + secondPart); } else { return appendPrefixAndSuffix(parts[0].trim() + "Z"); } } final String time = parts[0].trim(); final String offSet = parts[2].trim(); return appendPrefixAndSuffix(time + offSet); } }
TimeValueFormatter { public String toRaw(final String input) { if (!input.contains(" ")) { return appendPrefixAndSuffix(input); } final String[] parts = input.split(" "); if (parts.length == 2) { final String secondPart = parts[1].trim(); if (timeZoneProvider.isTimeZone(secondPart)) { return appendPrefixAndSuffix(parts[0].trim() + "@" + secondPart); } else { return appendPrefixAndSuffix(parts[0].trim() + "Z"); } } final String time = parts[0].trim(); final String offSet = parts[2].trim(); return appendPrefixAndSuffix(time + offSet); } @Inject  TimeValueFormatter(final TimeZoneProvider timeZoneProvider); }
TimeValueFormatter { public String toRaw(final String input) { if (!input.contains(" ")) { return appendPrefixAndSuffix(input); } final String[] parts = input.split(" "); if (parts.length == 2) { final String secondPart = parts[1].trim(); if (timeZoneProvider.isTimeZone(secondPart)) { return appendPrefixAndSuffix(parts[0].trim() + "@" + secondPart); } else { return appendPrefixAndSuffix(parts[0].trim() + "Z"); } } final String time = parts[0].trim(); final String offSet = parts[2].trim(); return appendPrefixAndSuffix(time + offSet); } @Inject  TimeValueFormatter(final TimeZoneProvider timeZoneProvider); String toDisplay(final String input); String buildRawValue(final String time,
                                final String selectedTimeZone); TimeValue getTimeValue(final String val); String toRaw(final String input); String getTime(final String raw); String appendPrefixAndSuffix(final String input); }
TimeValueFormatter { public String toRaw(final String input) { if (!input.contains(" ")) { return appendPrefixAndSuffix(input); } final String[] parts = input.split(" "); if (parts.length == 2) { final String secondPart = parts[1].trim(); if (timeZoneProvider.isTimeZone(secondPart)) { return appendPrefixAndSuffix(parts[0].trim() + "@" + secondPart); } else { return appendPrefixAndSuffix(parts[0].trim() + "Z"); } } final String time = parts[0].trim(); final String offSet = parts[2].trim(); return appendPrefixAndSuffix(time + offSet); } @Inject  TimeValueFormatter(final TimeZoneProvider timeZoneProvider); String toDisplay(final String input); String buildRawValue(final String time,
                                final String selectedTimeZone); TimeValue getTimeValue(final String val); String toRaw(final String input); String getTime(final String raw); String appendPrefixAndSuffix(final String input);  }