use of java.text.DateFormat in project Honu by jboulon.
the class ISO8601 method getTime.
/**
* Date in ISO8601 format:
* yyyy-MM-dd'T'HH:mm:ss,SSS
* @param dateStr
* @return
* @throws ParseException
*/
public static long getTime(String dateStr) throws ParseException {
synchronized (calendar) {
calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
DateFormat outdfm = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss,SSS");
outdfm.setTimeZone(TimeZone.getTimeZone("GMT"));
calendar.setTime(outdfm.parse(dateStr));
return calendar.getTimeInMillis();
}
}
use of java.text.DateFormat in project Openfire by igniterealtime.
the class StatsAction method formatTimeLong.
/**
* Formats a given time using the <code>DateFormat.MEDIUM</code>. In the 'en' locale, this
* should result in a time formatted like this: 4:59:23 PM. The seconds are necessary when
* displaying time in the conversation scroller.
* @param time
* @return string a date formatted using DateFormat.MEDIUM
*/
public static String formatTimeLong(Date time) {
DateFormat formatter = DateFormat.getTimeInstance(DateFormat.MEDIUM, JiveGlobals.getLocale());
formatter.setTimeZone(JiveGlobals.getTimeZone());
return formatter.format(time);
}
use of java.text.DateFormat in project hs4j by killme2008.
the class ResultSetImpl method getDateFromString.
private Date getDateFromString(String stringVal, Calendar cal) throws SQLException {
if (stringVal == null) {
this.lastWasNull = true;
return null;
}
String val = stringVal.trim();
if (val.length() == 0) {
this.lastWasNull = true;
return null;
}
if (val.equals("0") || val.equals("0000-00-00") || val.equals("0000-00-00 00:00:00") || val.equals("00000000000000") || val.equals("0")) {
Calendar calendar = null;
if (cal != null) {
calendar = Calendar.getInstance(cal.getTimeZone());
} else {
calendar = Calendar.getInstance();
}
calendar.set(Calendar.YEAR, 1);
calendar.set(Calendar.MONTH, 0);
calendar.set(Calendar.DAY_OF_MONTH, 1);
return new Date(calendar.getTimeInMillis());
}
DateFormat dateFormat = DateFormat.getDateTimeInstance();
if (cal != null) {
TimeZone timeZone = cal.getTimeZone();
dateFormat.setTimeZone(timeZone);
}
try {
return new Date(dateFormat.parse(val).getTime());
} catch (ParseException e) {
throw new SQLException("Parse date failure:" + val);
}
}
use of java.text.DateFormat in project head by mifos.
the class DateTag method getUserFormat.
String getUserFormat(Locale locale) {
// the following line will be removed when date is localized
locale = Locale.UK;
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
return ((SimpleDateFormat) df).toPattern();
}
use of java.text.DateFormat in project head by mifos.
the class LocalizationConverter method getDateSeparator.
public String getDateSeparator(Locale locale, int dateFormat) {
String separator = "";
DateFormat format = DateFormat.getDateInstance(dateFormat, locale);
String now = format.format(new DateTimeService().getCurrentJavaDateTime());
char[] chArray = now.toCharArray();
for (char element : chArray) {
if (Character.isDigit(element) == false) {
separator = String.valueOf(element);
break;
}
}
return separator;
}
Aggregations