SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", java.util.Locale.getDefault());
private static ResourceBundle getResourceBundle(Locale locale) { if (locale == null) { locale = Locale.getDefault(); } return ResourceBundle.getBundle(RESOURCE_NAME, locale); } }
private String _getCurrentTimestamp() { return new SimpleDateFormat("k:m:s:S a", Locale.getDefault()).format(new Date()); } }
private String getDateTime() { SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss", Locale.getDefault()); Date date = new Date(); return dateFormat.format(date); } ContentValues values = new ContentValues(); values.put('username', 'ravitamada'); values.put('created_at', getDateTime()); // insert the row long id = db.insert('users', null, values);
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.getDefault()); Date currentLocalTime = calendar.getTime(); DateFormat date = new SimpleDateFormat("Z"); String localTime = date.format(currentLocalTime);
throws MissingResourceException Locale locale = Locale.getDefault(); return (ListResourceBundle)ResourceBundle.getBundle(className, locale); return (ListResourceBundle)ResourceBundle.getBundle( className, new Locale("en", "US")); throw new MissingResourceException( "Could not load any resource bundles." + className, className, "");
public static Locale getPreferredLocale(Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); String languageCode = sp.getString(context.getString(R.string.content_language_key), context.getString(R.string.default_language_value)); try { if (languageCode.length() == 2) { return new Locale(languageCode); } else if (languageCode.contains("_")) { String country = languageCode.substring(languageCode.indexOf("_"), languageCode.length()); return new Locale(languageCode.substring(0, 2), country); } } catch (Exception ignored) { } return Locale.getDefault(); }
/** * Gets the ResourceBundle AKA language package. * Used for choosing the language of the UI. * * @return Returns the default resource bundle using the language specified in the config file. */ public static ResourceBundle getResourceBundle(String langSelect) { if (langSelect == null) { if (!getConfigString("lang", "").equals("")) { String[] langCode = getConfigString("lang", "").split("_"); LOGGER.info("Setting locale to " + getConfigString("lang", "")); return ResourceBundle.getBundle("LabelsBundle", new Locale(langCode[0], langCode[1]), new UTF8Control()); } } else { String[] langCode = langSelect.split("_"); LOGGER.info("Setting locale to " + langSelect); return ResourceBundle.getBundle("LabelsBundle", new Locale(langCode[0], langCode[1]), new UTF8Control()); } try { LOGGER.info("Setting locale to default"); return ResourceBundle.getBundle("LabelsBundle", Locale.getDefault(), new UTF8Control()); } catch (MissingResourceException e) { LOGGER.info("Setting locale to root"); return ResourceBundle.getBundle("LabelsBundle", Locale.ROOT); } }
if (cl != null) { try { return ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), cl); } catch (MissingResourceException ignored) { if (cl != null) { try { return ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), cl); } catch (MissingResourceException ignored) { throw new MissingResourceException("Failed to load the specified resource bundle \"" + resourceBundleName + "\"", resourceBundleName, null);
public Date getTimestamp() { try { // Parse the timestamp into a Date object return new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.getDefault()) .parse(timestamp); } catch (IllegalArgumentException | ParseException e) { // Return current Date return new Date(); } }
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); try { mediaFile = File.createTempFile(
/** * Get a user friendly date and time representation from a given {@link Date}. * The default {@link Locale} is used. * * @param date concerned {@link Date} instance * @return a string of the format "yyyy-MM-dd_HH-mm-ss.SSS" for the corresponding date */ public static String getDateTime(Date date) { return new SimpleDateFormat(DATE_TIME_PATTERN, Locale.getDefault()).format(date); } }
SimpleDateFormat dateFormat = new SimpleDateFormat( "LLLL", Locale.getDefault() ); dateFormat.format( date );
Locale locale = Locale.getDefault(); String suffix = getResourceSuffix(locale); return (XSLTErrorResources) ResourceBundle.getBundle(className + suffix, locale); return (XSLTErrorResources) ResourceBundle.getBundle(className, new Locale("en", "US")); throw new MissingResourceException( "Could not load any resource bundles.", className, "");
public CustomDateFormatExtractor(String timePattern, String localeString) { Locale locale = (localeString != null)? new Locale(localeString): Locale.getDefault(); this.timePattern = timePattern; builder = new FormatterBuilder(); builder.locale = locale; parsePatternTo(builder, timePattern); textPattern = builder.toTextPattern(); }
private GT() { try { //JCP! if mvn.project.property.postgresql.jdbc.spec < "JDBC4.1" //JCP> _bundle = ResourceBundle.getBundle("org.postgresql.translation.messages"); //JCP! else _bundle = ResourceBundle.getBundle("org.postgresql.translation.messages", Locale.getDefault(Locale.Category.DISPLAY)); //JCP! endif } catch (MissingResourceException mre) { // translation files have not been installed _bundle = null; } }
static File createImageFile(Context context) { File mFile = null; try { String timeStamp = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).format(new Date()); String imageName = String.format("aw_%s.jpg", timeStamp); mFile = createFileByName(context, imageName, true); } catch (Throwable e) { } return mFile; }
final DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()); final File heapDumpFile = new File(path, "heapdump-" + Parameters.getHostName() + '-' + PID.getPID() + '-' + dateFormat.format(new Date()) + ".hprof"); if (heapDumpFile.exists()) { try {
private DateFormat determineDateFormat() { return dfStr == null ? null : new SimpleDateFormat(dfStr, Locale.getDefault()); } }
public static String formateDateFromstring(String inputFormat, String outputFormat, String inputDate){ Date parsed = null; String outputDate = ""; SimpleDateFormat df_input = new SimpleDateFormat(inputFormat, java.util.Locale.getDefault()); SimpleDateFormat df_output = new SimpleDateFormat(outputFormat, java.util.Locale.getDefault()); try { parsed = df_input.parse(inputDate); outputDate = df_output.format(parsed); } catch (ParseException e) { LOGE(TAG, "ParseException - dateFormat"); } return outputDate; }