Java Time to String timeToString(Date d, String tzString)

Here you can find the source of timeToString(Date d, String tzString)

Description

time To String

License

Open Source License

Declaration

public static String timeToString(Date d, String tzString) 

Method Source Code

//package com.java2s;
/*/*w ww. java 2 s .co  m*/
 * jPOS Project [http://jpos.org]
 * Copyright (C) 2000-2012 Alejandro P. Revilla
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Date;

import java.util.TimeZone;
import java.text.DateFormat;

public class Main {
    public static String timeToString(Date d, String tzString) {
        DateFormat df = (DateFormat) DateFormat.getTimeInstance(
                DateFormat.SHORT).clone();
        if (tzString != null)
            df.setTimeZone(TimeZone.getTimeZone(tzString));
        return df.format(d);
    }

    public static String timeToString(Date d) {
        return timeToString(d, null);
    }
}

Related

  1. timeToFullString(long time)
  2. timeToFullString(long time, boolean longNames)
  3. timeToStr(int time)
  4. timeToStr(String time)
  5. timeToString(Calendar date)
  6. timeToString(Date date)
  7. timeToString(double d)
  8. timeToString(double time, boolean longNames)
  9. timeToString(final Date date)