Set ClassPath
export CLASSPATH=$CLASSPATH:/java/build/classes/
Set Path
export PATH=$PATH:/mnt/home/jdk1.6/bin/
Set ClassPath
export CLASSPATH=$CLASSPATH:/java/build/classes/
Set Path
export PATH=$PATH:/mnt/home/jdk1.6/bin/
ComparatorChain chain = new ComparatorChain();
Comparator comp = new BeanComparator("firstname", new NullComparator(true));
chain.addComparator(comp,true);
comp = new BeanComparator("lastname", new NullComparator(true));
chain.addComparator(comp);
Collections.sort(customerlist,chain);
NullComparator(true) <– true places null values at the front of the list
chain.addComparator(comp,true); <– true reverse the list
customerlist = list of dynabeans
DecimalFormatSymbols sym = new DecimalFormatSymbols();
sym.setGroupingSeparator('-');
NumberFormat accFormatter = new DecimalFormat("###,###,####,######",sym);
BigDecimal num = new BigDecimal("1111111111111111");
String formattedNum = accFormatter.format(num);
formattedNum = 111-111-1111-111111
Create list of dates (last 6 months) to populate listbox in .jsp.
// get search date listbox
DynaBean dateBean = new LazyDynaBean();
List<DynaBean> dateList = new ArrayList<DynaBean>();
SimpleDateFormat formatter = new SimpleDateFormat("MMM yyyy");
// display 6 months starting from current month
Calendar cal = Calendar.getInstance();
// get current date
cal.setTime(new Date());
for(int i=0; i<5; i++) {
dateBean = new LazyDynaBean();
dateBean.set("property", formatter.format(cal.getTime()));
dateBean.set("value", cal.getTime());
// add to list
dateList.add (dateBean);
// subtract 1 month
cal.add(Calendar.MONTH, -1);
}
// send to form bean (type="java.util.List")
PropertyUtils.setUtils(form, "datelist", dateList);
in .jsp
<bean:define id="dates" name="MyFormName" property="datelist"/>
<html:select property="s_valueDate" value='<%= request.getParameter("s_valueDate") %>'> <html:options collection="dates" property="value" labelProperty="property"/>
</html:select>
String valueDate= "09/2007";
Calendar cal = Calendar.getInstance();
cal.setTime(new SimpleDateFormat("MM/yyyy").parse(valueDate));
String endDate = cal.getActualMaximum(Calendar.DAY_OF_MONTH) + "/"+ valueDate;
endDate = 30/09/2007;
<head>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
</head>
warghhhh..why are date datatypes such a headache?!
Tis was the easiest way i could think off without using some gungho algorithm
Date -> String -> Date
// format current date (without time) and convert to string
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
String todayDate = formatter.format(new Date());
Date formattedDate = null;
try {
// convert date string back to Date datatype
formattedDate = formatter.parse(todayDate);
} catch (ParseException e) {
log.error("Parse today date error");
}
DecimalFormat formatter = new DecimalFormat(#,###);
out.print(formatter.format('1000'));