Here you can find the source of getTimeByFormat(Date date, String format)
Parameter | Description |
---|---|
date | the date |
format | the format |
public static String getTimeByFormat(Date date, String format)
//package com.java2s; /*//www .j a v a 2 s .c o m * Copyright(C) 2016 thuebannhadat.com.vn. All rights reserved. * * This software is the confidential and proprietary information of * thuebannhadat.com.vn. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the license * agreement you entered into with thuebannhadat.com.vn. */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /** * Gets the time by format. * * @param date * the date * @param format * the format * @return the time by format */ public static String getTimeByFormat(Date date, String format) { return format(date, format, Locale.ENGLISH); } /** * Format date to String. * * @param date * the date * @param format * the format * @param locale * the locale * @return the string */ public static String format(Date date, String format, Locale locale) { if (date != null && format != null && locale != null) { return new SimpleDateFormat(format, Locale.ENGLISH).format(date); } return null; } }