下面列出了org.joda.time.format.DateTimeFormat#shortTime ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public String getIsoDateWithLocalTime(Date dateToConvert) {
if (dateToConvert == null) {
return null;
}
DateTime dt = new DateTime(dateToConvert);
DateTimeFormatter fmt = ISODateTimeFormat.yearMonthDay();
DateTimeFormatter localFmt = fmt.withLocale(new ResourceLoader().getLocale());
DateTimeFormatter fmtTime = DateTimeFormat.shortTime();
DateTimeFormatter localFmtTime = fmtTime.withLocale(new ResourceLoader().getLocale());
// If the client browser is in a different timezone than server, need to modify date
if (m_client_timezone !=null && m_server_timezone!=null && !m_client_timezone.hasSameRules(m_server_timezone)) {
DateTimeZone dateTimeZone = DateTimeZone.forTimeZone(m_client_timezone);
localFmt = localFmt.withZone(dateTimeZone);
localFmtTime = localFmtTime.withZone(dateTimeZone);
}
return dt.toString(localFmt) + " " + dt.toString(localFmtTime);
}
public String getIsoDateWithLocalTime(Date dateToConvert) {
if (dateToConvert == null) {
return null;
}
DateTime dt = new DateTime(dateToConvert);
DateTimeFormatter fmt = ISODateTimeFormat.yearMonthDay();
DateTimeFormatter localFmt = fmt.withLocale(new ResourceLoader().getLocale());
DateTimeFormatter fmtTime = DateTimeFormat.shortTime();
DateTimeFormatter localFmtTime = fmtTime.withLocale(new ResourceLoader().getLocale());
// If the client browser is in a different timezone than server, need to modify date
if (m_client_timezone !=null && m_server_timezone!=null && !m_client_timezone.hasSameRules(m_server_timezone)) {
DateTimeZone dateTimeZone = DateTimeZone.forTimeZone(m_client_timezone);
localFmt = localFmt.withZone(dateTimeZone);
localFmtTime = localFmtTime.withZone(dateTimeZone);
}
return dt.toString(localFmt) + " " + dt.toString(localFmtTime);
}
private DateTimeFormatter getFallbackFormatter(Type type) {
switch (type) {
case DATE: return DateTimeFormat.shortDate();
case TIME: return DateTimeFormat.shortTime();
default: return DateTimeFormat.shortDateTime();
}
}
private DateTimeFormatter getFallbackFormatter(Type type) {
switch (type) {
case DATE: return DateTimeFormat.shortDate();
case TIME: return DateTimeFormat.shortTime();
default: return DateTimeFormat.shortDateTime();
}
}
private DateTimeFormatter getFallbackFormatter(Type type) {
switch (type) {
case DATE: return DateTimeFormat.shortDate();
case TIME: return DateTimeFormat.shortTime();
default: return DateTimeFormat.shortDateTime();
}
}
private DateTimeFormatter getFallbackFormatter(Type type) {
switch (type) {
case DATE: return DateTimeFormat.shortDate();
case TIME: return DateTimeFormat.shortTime();
default: return DateTimeFormat.shortDateTime();
}
}