Here you can find the source of parseDateToStr(Date date)
Parameter | Description |
---|---|
date | : date to be converted |
public static String[] parseDateToStr(Date date)
//package com.java2s; /*//from www . ja v a 2 s. c o m * CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF * Institute of Systems Science, National University of Singapore * * Copyright 2012 Team 4(Part-Time), ISS, NUS, Singapore. All rights reserved. * Use of this source code is subjected to the terms of the applicable license * agreement. * * ----------------------------------------------------------------- * REVISION HISTORY * ----------------------------------------------------------------- * DATE AUTHOR REVISION DESCRIPTION * 10 March 2012 Chen Changfeng 0.1 Class creating * * * * * */ import java.text.SimpleDateFormat; import java.util.*; public class Main { /** * Parse Date to array of string * * @param date : date to be converted * @return array of string where String[0] = dd, String[1] = mm, String[2] = yyyy */ public static String[] parseDateToStr(Date date) { String strFormat = "ddMMyyyy"; SimpleDateFormat dateFormat = new SimpleDateFormat(strFormat); String[] arrDate = new String[3]; String strDate = null; if (date == null) return arrDate; strDate = dateFormat.format(date); arrDate[0] = strDate.substring(0, 2); arrDate[1] = strDate.substring(2, 4); arrDate[2] = strDate.substring(4); return arrDate; } /** * Get the formatted string of the given date instance based on the * date format provided. * <p> * @param date The date that needs to be formatted. * @param format The format to be applied to the date. * @return The formatted Date String. */ public static String format(Date date, String format) { if (date == null || format == null) return null; SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }