Java Calendar Format formatDate(String formats, Calendar date)

Here you can find the source of formatDate(String formats, Calendar date)

Description

format Date

License

Open Source License

Declaration

@Deprecated
    public static String formatDate(String formats, Calendar date) 

Method Source Code

//package com.java2s;
/*//from  w ww  .ja  v a2 s.  c om
 * Copyright (C) 2006-2016 Talend Inc. - www.talend.com
 * 
 * This source code is available under agreement available at
 * %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
 * 
 * You should have received a copy of the agreement along with this program; if not, write to Talend SA 9 rue Pages
 * 92150 Suresnes, France
 */

import java.util.Calendar;

public class Main {
    public static String DATE_FORMAT_PREFIX = "%t";

    @Deprecated
    public static String formatDate(String formats, Calendar date) {
        String formatValue = formats;
        if (formats.startsWith(DATE_FORMAT_PREFIX)) {
            while (true) {
                if (!formatValue.contains(DATE_FORMAT_PREFIX)) {
                    break;
                }
                String format = formatValue.substring(formatValue.indexOf(DATE_FORMAT_PREFIX),
                        formatValue.indexOf(DATE_FORMAT_PREFIX) + 3);
                String valueStr = String.format(java.util.Locale.ENGLISH, format, date);
                formatValue = formatValue.replace(format, valueStr);
            }
        } else {
            formatValue = String.format(java.util.Locale.ENGLISH, formats, date);
        }

        return formatValue;
    }
}

Related

  1. formatDate(Calendar date)
  2. formatDate(Calendar date)
  3. formatDate(Calendar date)
  4. formatDate(Calendar date, int precision)
  5. FormatDate(Calendar p_date, String p_separator)
  6. formatDateTime(Calendar cal)
  7. formatDateTimeUTC(Calendar datetime)
  8. formatDay(java.util.Calendar d)
  9. formatDuration(Calendar t1, Calendar t2, boolean precise)