/*
 * Copyright (c) 2015 Diona Ltd.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of Diona
 * ("Confidential Information"). 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 Diona.
 */
package org.odk.collect.android.utilities;

import android.content.Context;
import android.text.format.DateUtils;

import java.util.Date;

/**
 * Formats
 */
public final class DateFormatter {

  /**
   * Format the text selected from a date picker for display in a TextView to the user.
   *
   * @param context
   *     an active Context.
   * @param date
   *     the date to format.
   *
   * @return the formatted date.
   */
  public static String formatDatePickerOutput(final Context context, final Date date) {
    if (date == null) {
      return "";
    }
    final int flags = DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
    return DateUtils.formatDateTime(context, date.getTime(), flags);
  }
}
