本文整理了Java中java.text.SimpleDateFormat.getTimeInstance()
方法的一些代码示例,展示了SimpleDateFormat.getTimeInstance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SimpleDateFormat.getTimeInstance()
方法的具体详情如下:
包路径:java.text.SimpleDateFormat
类名称:SimpleDateFormat
方法名:getTimeInstance
暂无
代码示例来源:origin: rey5137/material
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
TimePickerDialog dialog = (TimePickerDialog)fragment.getDialog();
Toast.makeText(mActivity, "Time is " + dialog.getFormattedTime(SimpleDateFormat.getTimeInstance()), Toast.LENGTH_SHORT).show();
super.onPositiveActionClicked(fragment);
}
代码示例来源:origin: plutext/docx4j
private static String formatDate(FldSimpleModel model, String format, Date date, String lang) {
DateFormat dateFormat = null;
if ((format != null) && (format.length() > 0)) {
SimpleDateFormat simpleDateFormat = getSimpleDateFormat(lang);
simpleDateFormat.applyPattern(convertDatePattern(format));
dateFormat = simpleDateFormat;
}
else {
dateFormat = (model.getFldName().indexOf("DATE") > -1 ?
SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT) :
SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT));
}
return dateFormat.format(date);
}
代码示例来源: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: com.jidesoft/jide-oss
/**
* Creates a date spinner using locale default as the format string.
*/
public DateSpinner() {
this(((SimpleDateFormat) SimpleDateFormat.getTimeInstance(SimpleDateFormat.DEFAULT, Locale.getDefault())).toPattern());
}
代码示例来源:origin: org.rhq/test-utils
private static String getDateTime() {
return SimpleDateFormat.getTimeInstance().format(new Date());
}
代码示例来源:origin: rhq-project/rhq
private static String getDateTime() {
return SimpleDateFormat.getTimeInstance().format(new Date());
}
代码示例来源:origin: matburt/mobileorg-android
/**
* Format the string according to the parameter isDate
* @param isDate: date formating or time formating
* @return
*/
public String toString(boolean isDate) {
GregorianCalendar calendar = new GregorianCalendar(year, monthOfYear, dayOfMonth, startTimeOfDay, startMinute);
calendar.setTimeZone(TimeZone.getTimeZone("GMT0"));
DateFormat instance = isDate ? SimpleDateFormat.getDateInstance() : SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
instance.setTimeZone(TimeZone.getTimeZone("GMT0"));
return instance.format(calendar.getTime());
}
代码示例来源:origin: macoscope/RoomBookerMVP
private void initDateTimeFormat() {
simpleTimeFormat = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
simpleDateFormat = SimpleDateFormat.getDateInstance();
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
private String formatDate(long time) {
Calendar today = Calendar.getInstance();
today.clear(Calendar.HOUR_OF_DAY);
today.clear(Calendar.MINUTE);
today.clear(Calendar.SECOND);
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(time);
DateFormat format;
if (cal.after(today)) {
format = SimpleDateFormat.getTimeInstance();
} else {
format = SimpleDateFormat.getDateTimeInstance();
}
return format.format(new Date(time));
}
}
代码示例来源:origin: Gwokhov/Deadline
public static String dateToString(Date date, int format) {
switch (format) {
case DATE:
return new SimpleDateFormat("MM/d").format(date);
case TIME:
return SimpleDateFormat.getTimeInstance(DateFormat.SHORT).format(date);
case MEDIUM:
return SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(date);
default:
return SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(date);
}
}
代码示例来源:origin: org.jabylon/rest.ui
protected String format(Date nextExecution) {
long current = System.currentTimeMillis();
//if it's less than 15 hours away only show the time
if(nextExecution.getTime()-current<TimeUnit.HOURS.toMillis(23))
return SimpleDateFormat.getTimeInstance(DateFormat.SHORT,getLocale()).format(nextExecution);
return SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT,SimpleDateFormat.SHORT,getLocale()).format(nextExecution);
}
代码示例来源:origin: com.vaadin/vaadin-compatibility-server
/**
* Gets currently active time format. Value is either TimeFormat.Format12H
* or TimeFormat.Format24H.
*
* @return TimeFormat Format for the time.
*/
public TimeFormat getTimeFormat() {
if (currentTimeFormat == null) {
SimpleDateFormat f;
if (getLocale() == null) {
f = (SimpleDateFormat) SimpleDateFormat
.getTimeInstance(SimpleDateFormat.SHORT);
} else {
f = (SimpleDateFormat) SimpleDateFormat
.getTimeInstance(SimpleDateFormat.SHORT, getLocale());
}
String p = f.toPattern();
if (p.indexOf("HH") != -1 || p.indexOf("H") != -1) {
return TimeFormat.Format24H;
}
return TimeFormat.Format12H;
}
return currentTimeFormat;
}
代码示例来源:origin: info.magnolia/magnolia-core
public static String format(Date date, String formatPattern, Locale locale) {
if (date == null) {
return StringUtils.EMPTY;
}
if (formatPattern == null) {
formatPattern = FORMAT_DEFAULTPATTERN;
}
if (FORMAT_DATE_SHORT.equals(formatPattern)) {
return SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT, locale).format(date);
} else if (FORMAT_DATE_MEDIUM.equals(formatPattern)) {
return SimpleDateFormat.getDateInstance(SimpleDateFormat.MEDIUM, locale).format(date);
} else if (FORMAT_DATE_LONG.equals(formatPattern)) {
return SimpleDateFormat.getDateInstance(SimpleDateFormat.LONG, locale).format(date);
} else if (FORMAT_TIME_SHORT.equals(formatPattern)) {
return SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT, locale).format(date);
} else if (FORMAT_TIME_MEDIUM.equals(formatPattern)) {
return SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM, locale).format(date);
} else if (FORMAT_TIME_LONG.equals(formatPattern)) {
return SimpleDateFormat.getTimeInstance(SimpleDateFormat.LONG, locale).format(date);
} else if (FORMAT_DATETIME_SHORT.equals(formatPattern)) {
return SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT, locale).format(date);
} else if (FORMAT_DATETIME_MEDIUM.equals(formatPattern)) {
return SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM, SimpleDateFormat.MEDIUM, locale).format(date);
} else if (FORMAT_DATETIME_LONG.equals(formatPattern)) {
return SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.LONG, SimpleDateFormat.LONG, locale).format(date);
} else {
return DateFormatUtils.format(date, formatPattern, locale);
}
}
代码示例来源:origin: org.docx4j/docx4j
private static String formatDate(FldSimpleModel model, String format, Date date, String lang) {
DateFormat dateFormat = null;
if ((format != null) && (format.length() > 0)) {
SimpleDateFormat simpleDateFormat = getSimpleDateFormat(lang);
simpleDateFormat.applyPattern(convertDatePattern(format));
dateFormat = simpleDateFormat;
}
else {
dateFormat = (model.getFldName().indexOf("DATE") > -1 ?
SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT) :
SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT));
}
return dateFormat.format(date);
}
代码示例来源:origin: com.axway.ats.framework/ats-core
/**
* Set the time on a windows system
*
* @param calendar the time to set
*/
private void setWindowsTime( Calendar calendar ) throws Exception {
// we are using the default date format and the system specific time format
// set the date
String dateArguments = String.format("%1$02d-%2$02d-%3$02d", calendar.get(Calendar.DAY_OF_MONTH),
calendar.get(Calendar.MONTH) + 1,
calendar.get(Calendar.YEAR));
LocalProcessExecutor processExecutor = new LocalProcessExecutor(HostUtils.LOCAL_HOST_IPv4,
"cmd /c date " + dateArguments);
processExecutor.execute();
// set the time
String timeArguments = SimpleDateFormat.getTimeInstance().format(calendar.getTime());
processExecutor = new LocalProcessExecutor(HostUtils.LOCAL_HOST_IPv4,
"cmd /c time " + timeArguments);
processExecutor.execute();
}
代码示例来源:origin: martin-grofcik/activiti-crystalball
@Override
public void handle(SimulationEvent event) {
String taskId = (String) event.getProperty("task");
// fulfill variables
@SuppressWarnings("unchecked")
Map<String, Object> variables = (Map<String, Object>) event.getProperty("variables");
SimulationRunContext.getTaskService().complete( taskId, variables );
log.debug( SimpleDateFormat.getTimeInstance().format( new Date(event.getSimulationTime())) +": completed taskId "+ taskId + " variable update [" + variables +"]");
}
代码示例来源:origin: org.springframework/spring-binding
public Formatter getTimeFormatter(Style style) {
return new DateFormatter(SimpleDateFormat.getTimeInstance(style.shortValue(), getLocale()));
}
代码示例来源:origin: martin-grofcik/activiti-crystalball
@Override
public void handle(SimulationEvent event) {
TaskEntity task = (TaskEntity) event.getProperty();
if (claimTask(task)) {
// create complete task event
Map<String, Object> props = new HashMap<String, Object>();
props.put( "task", task.getId());
Map<String, Object> variables = new HashMap<String, Object>();
long userTaskDelta = userTaskExecutor.simulateTaskExecution(task, variables);
props.put( "variables", variables);
SimulationEvent completeEvent = new SimulationEvent( ClockUtil.getCurrentTime().getTime() + userTaskDelta, SimulationEvent.TYPE_TASK_COMPLETE, props);
// schedule complete task event
SimulationRunContext.getEventCalendar().addEvent( completeEvent);
log.debug( SimpleDateFormat.getTimeInstance().format( new Date(event.getSimulationTime())) +": claimed {}, name: {}, assignee: {}", task, task.getName(), task.getAssignee());
}
}
代码示例来源:origin: martin-grofcik/activiti-crystalball
@Override
public void handle(SimulationEvent event) {
TaskEntity task = (TaskEntity) event.getProperty();
SimulationRunContext.getTaskService().claim(task.getId(), DEFAULT_USER);
task.setAssignee( DEFAULT_USER );
// create complete task event
Map<String, Object> props = new HashMap<String, Object>();
props.put( "task", task.getId());
Map<String, Object> variables = new HashMap<String, Object>();
long userTaskDelta = userTaskExecutor.simulateTaskExecution(task, variables);
props.put( "variables", variables);
SimulationEvent completeEvent = new SimulationEvent( ClockUtil.getCurrentTime().getTime() + userTaskDelta, SimulationEvent.TYPE_TASK_COMPLETE, props);
// schedule complete task event
SimulationRunContext.getEventCalendar().addEvent( completeEvent);
log.debug( SimpleDateFormat.getTimeInstance().format( new Date(event.getSimulationTime())) +": claimed {}, name: {}, assignee: {}", task, task.getName(), task.getAssignee());
}
代码示例来源:origin: br.com.tecsinapse/tecsinapse-data-io
public ExporterFormatter(Locale locale) {
this.locale = locale;
this.dateTimeFormat = (SimpleDateFormat) SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale);
this.dateFormat = (SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.MEDIUM, locale);
this.timeFormat = (SimpleDateFormat) SimpleDateFormat.getTimeInstance(DateFormat.SHORT, locale);
this.decimalFormat = (DecimalFormat) DecimalFormat.getInstance(locale);
this.integerFormat = (DecimalFormat) DecimalFormat.getIntegerInstance(locale);
this.currencyFormat = (DecimalFormat) DecimalFormat.getCurrencyInstance(locale == Locale.ENGLISH ? Locale.US : locale);
this.cellDateTimeFormat = DateFormatConverter.convert(locale, dateTimeFormat.toPattern());
this.cellDateFormat = DateFormatConverter.convert(locale, dateFormat.toPattern());
this.cellTimeFormat = DateFormatConverter.convert(locale, timeFormat.toPattern());
this.cellDecimalFormat = DateFormatConverter.convert(locale, decimalFormat.toPattern());
this.cellIntegerFormat = DateFormatConverter.convert(locale, integerFormat.toPattern());
this.cellCurrencyFormat = DateFormatConverter.convert(locale, getCurrencyFormatString());
}
内容来源于网络,如有侵权,请联系作者删除!