Java Date ISO Parse toStringForComparison(Date date)

Here you can find the source of toStringForComparison(Date date)

Description

to String For Comparison

License

BSD License

Parameter

Parameter Description
date the Date object

Return

string date in "yyyy/MM/dd" format

Declaration

public static String toStringForComparison(Date date) 

Method Source Code

//package com.java2s;
/**//from   ww  w  .j  av  a  2s  .  c  o m
 * Copyright 5AM Solutions Inc, ESAC, ScenPro & SAIC
 *
 * Distributed under the OSI-approved BSD 3-Clause License.
 * See http://ncip.github.com/caintegrator/LICENSE.txt for details.
 */

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Locale;

public class Main {
    /**
     * @param date the Date object
     * @return string date in "yyyy/MM/dd" format
     */
    public static String toStringForComparison(Date date) {
        if (date == null) {
            return "";
        }
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd", Locale.getDefault());
        return formatter.format(date);
    }
}

Related

  1. timestampAsIsoString(long timestamp)
  2. toCalendar(final String iso8601string)
  3. toDate(String isoDate)
  4. toIsoString(Calendar value)
  5. toIsoString(Date date)
  6. tryParse(String isoDateTime)