× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Jon,

FWIW,

We fought with this issue several years ago. We ended up creating a
design/framework where you allow the user to specify a "formatter" for
output when rending to the screen. IE.. So we keep the Date stored
internally as a java.sql.Date but we format it upon UI generation from the
business model.

A simple example:

http://www.planetjavainc.com/wowADDONDEV/runApp?id=121&_pj_lib=wowsamp

Example formatting code:

// Format Date with ISO
public class DateFormatterISOYearMonthDay implements IFormatter {

@Override
public String formatValue(Object value, Field field) {
if (value == null) {
// no value, return empty string
return "";
}

// create new date formatter, set up as (YearYearYearYear-MonthMonth-DayDay)
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// format the field value using the new date formatter
String s = formatter.format(value);
// return formatted value
return s;
}
}

// Format Date with Locale Default
public class LocaleSpecificDateFormatter implements IFormatter {

@Override
public String formatValue(Object value, Field field) {
if (value == null) {
// no value, return empty string
return "";
}

String dateOut;
DateFormat dateFormatter;
Locale currentLocale = Locale.getDefault(); // get default java locale

dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT,
currentLocale); // set DateFormat based on locale
dateOut = dateFormatter.format(value); // format value
// return formatted value
return dateOut;
}


-Paul Holm

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.