Android Date Offset getDateAndTimeWithShortFormat(boolean withYear, int year, int month, int day, int hour, int minute)

Here you can find the source of getDateAndTimeWithShortFormat(boolean withYear, int year, int month, int day, int hour, int minute)

Description

get Date And Time With Short Format

License

Apache License

Declaration

public static String getDateAndTimeWithShortFormat(boolean withYear,
            int year, int month, int day, int hour, int minute) 

Method Source Code

//package com.java2s;
/*//from w w  w. j a v  a  2  s  .c o  m
 * Copyright (C) 2012 Kazuya (Kaz) Yokoyama <kazuya.yokoyama@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.text.SimpleDateFormat;

import java.util.GregorianCalendar;

public class Main {
    public static String getDateAndTimeWithShortFormat(boolean withYear,
            int year, int month, int day, int hour, int minute) {
        SimpleDateFormat dateTimeFormat;
        if (withYear) {
            dateTimeFormat = new SimpleDateFormat("EEE, MMM d, yyyy h:mma");
        } else {
            dateTimeFormat = new SimpleDateFormat("EEE, MMM d, h:mma");
        }
        return dateTimeFormat.format(new GregorianCalendar(year,
                (month - 1), day, hour, minute).getTime());
    }
}

Related

  1. getTimeWithFormat(int year, int month, int day, int hour, int minute)
  2. thirdDayWithHour()
  3. getDateFormOffset(int months, int days, int hours, int minutes)
  4. convertToUnixTimeOneDayLater(Date date)