本文整理了Java中java.text.SimpleDateFormat.getDateTimeInstance()
方法的一些代码示例,展示了SimpleDateFormat.getDateTimeInstance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SimpleDateFormat.getDateTimeInstance()
方法的具体详情如下:
包路径:java.text.SimpleDateFormat
类名称:SimpleDateFormat
方法名:getDateTimeInstance
暂无
代码示例来源:origin: plutext/docx4j
protected Map<String, SimpleDateFormat> initialValue() {
HashMap<String, SimpleDateFormat> hashMap = new HashMap<String, SimpleDateFormat>();
hashMap.put(null, (SimpleDateFormat)SimpleDateFormat.getDateTimeInstance());
return hashMap;
}
};
代码示例来源:origin: log4j/log4j
private synchronized void configure() {
_dateFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.FULL,
DateFormat.FULL,
getLocale());
_dateFormat.setTimeZone(getTimeZone());
if (_pattern != null) {
((SimpleDateFormat) _dateFormat).applyPattern(_pattern);
}
}
代码示例来源:origin: plutext/docx4j
/**
* @param language abbreviation like "fr-CA",
* @return SimpleDateFormat instance for specified language
* if null will @return SimpleDateFormat.getDateTimeInstance()
*/
private static SimpleDateFormat getSimpleDateFormat(String lang) {
Map<String, SimpleDateFormat> dateFormatsMap = DATE_FORMATS.get();
SimpleDateFormat dateFormat = dateFormatsMap.get(lang);
if (dateFormat == null) {
// dateFormat = (SimpleDateFormat)SimpleDateFormat.getDateTimeInstance(DateFormat.DEFAULT, 0, Locale.forLanguageTag(lang));
// Be Java 6 compatible
dateFormat = (SimpleDateFormat)SimpleDateFormat.getDateTimeInstance(DateFormat.DEFAULT, 0,
localeforLanguageTag(lang));
dateFormatsMap.put(lang, dateFormat);
}
return dateFormat;
}
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldHandleNullValuesFromSTRINGPrint() throws IOException {
final DateFormat dateFormat =
SimpleDateFormat.getDateTimeInstance(3, 1, Locale.getDefault());
final ConsumerRecord<String, Bytes> record = new ConsumerRecord<>(
"some-topic", 1, 1, "key", null);
final String formatted =
Format.STRING.maybeGetFormatter(
"some-topic", record, null, dateFormat).get().print(record);
assertThat(formatted, endsWith(", key , NULL\n"));
}
代码示例来源:origin: eclipse/paho.mqtt.android
/**
* Add an action to the history of the client
* @param action the history item to add
*/
public void addAction(String action) {
Object[] args = new String[1];
DateFormat dateTimeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
args[0] = dateTimeFormatter.format(new Date());
String timestamp = context.getString(R.string.timestamp, args);
history.add(action + timestamp);
notifyListeners(new PropertyChangeEvent(this, ActivityConstants.historyProperty, null, null));
}
代码示例来源:origin: eclipse/paho.mqtt.android
@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent){
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.message_list_item, parent, false);
TextView topicTextView = (TextView) rowView.findViewById(R.id.message_topic_text);
TextView messageTextView = (TextView) rowView.findViewById(R.id.message_text);
TextView dateTextView = (TextView) rowView.findViewById(R.id.message_date_text);
messageTextView.setText(new String(messages.get(position).getMessage().getPayload()));
topicTextView.setText(context.getString(R.string.topic_fmt, messages.get(position).getTopic()));
DateFormat dateTimeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
String shortDateStamp = dateTimeFormatter.format(messages.get(position).getTimestamp());
dateTextView.setText(context.getString(R.string.message_time_fmt, shortDateStamp));
return rowView;
}
}
代码示例来源:origin: vekexasia/android-edittext-validator
@SuppressLint("SimpleDateFormat")
@Override
public boolean isValid(EditText et) {
if (TextUtils.isEmpty(et.getText()))
return true;
String value = et.getText().toString();
for (String _format : formats) {
DateFormat format;
if ("DefaultDate".equalsIgnoreCase(_format)) {
format = SimpleDateFormat.getDateInstance();
} else if ("DefaultTime".equalsIgnoreCase(_format)) {
format = SimpleDateFormat.getTimeInstance();
} else if ("DefaultDateTime".equalsIgnoreCase(_format)) {
format = SimpleDateFormat.getDateTimeInstance();
} else {
format = new SimpleDateFormat(_format);
}
Date date = null;
try {
date = format.parse(value);
} catch (ParseException e) {
return false;
}
if (date != null) {
return true;
}
}
return false;
}
代码示例来源:origin: owlike/genson
public DateConverter(DateFormat dateFormat, boolean asTimeInMillis) {
if (dateFormat == null) dateFormat = SimpleDateFormat.getDateTimeInstance();
this.dateFormat = dateFormat;
this.asTimeInMillis = asTimeInMillis;
}
代码示例来源:origin: apache/metron
String outputDirName = outputDirFormatter.format(beginNS, endNS, filterImpl.queryToString(fields));
if(LOG.isDebugEnabled()) {
DateFormat format = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.LONG
, SimpleDateFormat.LONG
);
代码示例来源:origin: DSpace/DSpace
@Override
protected DateFormat initialValue() {
DateFormat dateTimeInstance = SimpleDateFormat.getDateTimeInstance();
dateTimeInstance.setTimeZone(UTC_ZONE);
return dateTimeInstance;
}
};
代码示例来源:origin: tinyMediaManager/tinyMediaManager
public String getDateAddedAsString() {
if (dateAdded == null) {
return "";
}
return SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.getDefault()).format(dateAdded);
}
代码示例来源:origin: espertechinc/esper
public void onComplexEvent(String theEvent) {
DateFormat dateFormat = SimpleDateFormat.getDateTimeInstance();
String date = dateFormat.format(new Date());
System.out.println("CEP: " + date + " " + theEvent);
}
}
代码示例来源:origin: toutatice-portail.cms/toutatice-portail-cms-nuxeo-taglib
/**
* Generate comment creation date DOM4J element.
*
* @param locale user locale
* @param date comment creation date
* @return DOM4J element
*/
private Element generateDate(Locale locale, Date date) {
DateFormat dateFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT, locale);
return DOM4JUtils.generateElement(HTMLConstants.SPAN, null, dateFormat.format(date));
}
代码示例来源:origin: org.apache.openejb/openejb-core
@Managed
public String getLatest() {
final long last = this.last.get();
if (last <= 0) {
return "-";
}
final DateFormat format = SimpleDateFormat.getDateTimeInstance();
return format.format(new Date(last));
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public String getMediumFormat(final long milliseconds, final boolean natural) {
if(-1 == milliseconds) {
return LocaleFactory.localizedString("Unknown");
}
final DateFormat format = SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
format.setTimeZone(TimeZone.getTimeZone(tz));
return format.format(milliseconds);
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public String getLongFormat(final long milliseconds, final boolean natural) {
if(-1 == milliseconds) {
return LocaleFactory.localizedString("Unknown");
}
final DateFormat format = SimpleDateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
format.setTimeZone(TimeZone.getTimeZone(tz));
return format.format(milliseconds);
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public String getShortFormat(final long milliseconds, final boolean natural) {
if(-1 == milliseconds) {
return LocaleFactory.localizedString("Unknown");
}
final DateFormat format = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
format.setTimeZone(TimeZone.getTimeZone(tz));
return format.format(milliseconds);
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
private synchronized void configure() {
_dateFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.FULL,
DateFormat.FULL,
getLocale());
_dateFormat.setTimeZone(getTimeZone());
if (_pattern != null) {
((SimpleDateFormat) _dateFormat).applyPattern(_pattern);
}
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Uses the current locale (user) to parse the date and time.
*
* @param dateStr Date or Calendar
* @return the String
*/
public static Date parseDateTime(String dateStr) throws ParseException {
DateFormat format = SimpleDateFormat.getDateTimeInstance(
FastDateFormat.SHORT,
FastDateFormat.SHORT,
MgnlContext.getLocale());
return (Date) format.parseObject(dateStr);
}
代码示例来源:origin: boonproject/boon
public static String getGMTString(Date date) {
/*
* To SL: Now I know what you mean work everywhere. :)
* We format our dates differently here.
* DAY/MONTH/YEAR although logical and done everywhere. :)
* --RMH
*/
DateFormat df = SimpleDateFormat.getDateTimeInstance( DateFormat.SHORT,
DateFormat.SHORT, Locale.FRANCE );
df.setTimeZone(TimeZone.getTimeZone("GMT"));
return df.format(date);
}
}
内容来源于网络,如有侵权,请联系作者删除!