Here you can find the source of dateToFMDate(Date date)
static public String dateToFMDate(Date date)
//package com.java2s; /*/*from w w w.j a v a 2s . com*/ * Copyright (C) 2007-2009 Medsphere Systems Corporation * All rights reserved. * * This source code contains the intellectual property * of its copyright holder(s), and is made available * under a license. If you do not know the terms of * the license, please stop and do not read further. * * Please read LICENSES for detailed information about * the license this source code file is available under. * Questions should be directed to legal@medsphere.com * */ import java.text.DecimalFormat; import java.util.Calendar; import java.util.Date; public class Main { private static DecimalFormat fmDatePartFormat = new DecimalFormat( "0000000"); static public String dateToFMDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); int year = cal.get(Calendar.YEAR) - 1700; int month = cal.get(Calendar.MONTH) + 1; int day = cal.get(Calendar.DAY_OF_MONTH); int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); int second = cal.get(Calendar.SECOND); int datePart = year * 10000 + month * 100 + day; StringBuffer result = new StringBuffer( fmDatePartFormat.format(datePart)); if (hour + minute + second != 0) { result.append("."); if (hour < 10) { result.append("0"); } result.append(Integer.toString(hour)); if (minute + second != 0) { if (minute < 10) { result.append("0"); } result.append(Integer.toString(minute)); if (second != 0) { if (second < 10) { result.append("0"); } result.append(Integer.toString(second)); } } } return result.toString(); } }