Here you can find the source of parseDateToString(final Date date, final String dateFormat, final String lang)
Parameter | Description |
---|---|
date | the Date to parse |
dateFormat | the date format |
lang | the language/locale |
public static String parseDateToString(final Date date, final String dateFormat, final String lang)
//package com.java2s; /**//from w ww.jav a2 s.c om * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ import com.google.common.base.Preconditions; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /** * Parses a date to a particular format and returns the formatted {@link String}. * @param date the {@link Date} to parse * @param dateFormat the date format * @param lang the language/locale * @return a date {@link String} formatted according to the date format and locale */ public static String parseDateToString(final Date date, final String dateFormat, final String lang) { Preconditions.checkNotNull(date); Preconditions.checkNotNull(dateFormat); Preconditions.checkNotNull(lang); final Locale locale = new Locale(lang); final SimpleDateFormat format = new SimpleDateFormat(dateFormat, locale); return format.format(date); } }