Java Code Examples for org.joda.time.LocalTime#toString()
The following examples show how to use
org.joda.time.LocalTime#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateTimeFunctions.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
public static String TIME(Integer hours, Integer minutes, Integer seconds, String timePattern){ if(hours==null || minutes==null || seconds==null) { if(log.isDebugEnabled()){ log.debug("None of the arguments can be null."); } return null; } LocalTime lt=new LocalTime(hours,minutes,seconds); if(timePattern==null) { return lt.toString(DateTimeFormat.longTime()); } else{ try{ // Try to convert to a pattern DateTimeFormatter dtf = DateTimeFormat.forPattern(timePattern); return lt.toString(dtf); } catch (IllegalArgumentException ex){ // Fallback to the default solution return lt.toString(DateTimeFormat.longTime()); } } }
Example 2
Source File: LocaleUtils.java From prayer-times-android with Apache License 2.0 | 5 votes |
@NonNull public static String formatTime(LocalTime localTime) { String time = localTime == null ? "00:00" : localTime.toString("HH:mm"); if (Preferences.CLOCK_12H.get() && time.contains(":")) { try { String fix = time.substring(0, time.indexOf(":")); String suffix = time.substring(time.indexOf(":")); int hour = Integer.parseInt(fix); if (hour == 0) { time = "00" + suffix + " AM"; } else if (hour < 12) { time = az(hour) + suffix + " AM"; } else if (hour == 12) { time = "12" + suffix + " PM"; } else { time = az(hour - 12) + suffix + " PM"; } } catch (Exception e) { Crashlytics.logException(e); return time; } } return formatNumber(time); }
Example 3
Source File: LocaleUtils.java From prayer-times-android with Apache License 2.0 | 5 votes |
@NonNull public static String formatTime(LocalTime localTime) { String time = localTime == null ? "00:00" : localTime.toString("HH:mm"); if (Preferences.CLOCK_12H.get() && time.contains(":")) { try { String fix = time.substring(0, time.indexOf(":")); String suffix = time.substring(time.indexOf(":")); int hour = Integer.parseInt(fix); if (hour == 0) { time = "00" + suffix + " AM"; } else if (hour < 12) { time = az(hour) + suffix + " AM"; } else if (hour == 12) { time = "12" + suffix + " PM"; } else { time = az(hour - 12) + suffix + " PM"; } } catch (Exception e) { Crashlytics.logException(e); return time; } } return formatNumber(time); }
Example 4
Source File: StringColumnLocalTimeMapper.java From jadira with Apache License 2.0 | 5 votes |
@Override public String toNonNullValue(LocalTime value) { if (value.getMillisOfSecond() == 0) { if (value.getSecondOfMinute() == 0) { return Formatter.LOCAL_TIME_NOSECONDS_PRINTER.print(value); } return Formatter.LOCAL_TIME_NOMILLIS_PRINTER.print(value); } else { return value.toString(); } }
Example 5
Source File: FmtLocalTime.java From super-csv with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected String format(final LocalTime jodaType, final DateTimeFormatter formatter) { return jodaType.toString(formatter); }
Example 6
Source File: FmtLocalTime.java From super-csv with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected String format(final LocalTime jodaType, final String pattern, final Locale locale) { return jodaType.toString(pattern, locale); }
Example 7
Source File: FmtLocalTime.java From super-csv with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected String format(final LocalTime jodaType) { return jodaType.toString(); }
Example 8
Source File: LongColumnLocalTimeMapper.java From jadira with Apache License 2.0 | 4 votes |
@Override public String toNonNullString(LocalTime value) { return value.toString(); }
Example 9
Source File: TimestampColumnLocalTimeMapper.java From jadira with Apache License 2.0 | 4 votes |
@Override public String toNonNullString(LocalTime value) { return value.toString(); }
Example 10
Source File: TimeColumnLocalTimeMapper.java From jadira with Apache License 2.0 | 4 votes |
@Override public String toNonNullString(LocalTime value) { return value.toString(); }
Example 11
Source File: IntegerColumnLocalTimeMapper.java From jadira with Apache License 2.0 | 4 votes |
@Override public String toNonNullString(LocalTime value) { return value.toString(); }
Example 12
Source File: LocalTimeConverter.java From gson-jodatime-serialisers with MIT License | 2 votes |
/** * Gson invokes this call-back method during serialization when it encounters a field of the * specified type. <p> * * In the implementation of this call-back method, you should consider invoking * {@link JsonSerializationContext#serialize(Object, Type)} method to create JsonElements for any * non-trivial field of the {@code src} object. However, you should never invoke it on the * {@code src} object itself since that will cause an infinite loop (Gson will call your * call-back method again). * @param src the object that needs to be converted to Json. * @param typeOfSrc the actual type (fully genericized version) of the source object. * @return a JsonElement corresponding to the specified object. */ @Override public JsonElement serialize(LocalTime src, Type typeOfSrc, JsonSerializationContext context) { return new JsonPrimitive(src.toString(FORMATTER)); }