Java Long Number to Date convert(Long[] targets)

Here you can find the source of convert(Long[] targets)

Description

convert

License

Apache License

Declaration

public static String[] convert(Long[] targets) 

Method Source Code

//package com.java2s;
/*//from ww  w.  ja va 2  s. com
 * Copyright 2012 Kazumune Katagiri. (http://d.hatena.ne.jp/nemuzuka)
 *
 * 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.DecimalFormat;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import java.util.List;

public class Main {

    public static Long[] convert(String[] targets) {
        if (targets == null) {
            return new Long[0];
        }

        List<Long> list = new ArrayList<Long>();
        for (String target : targets) {
            list.add(Long.valueOf(target));
        }
        return list.toArray(new Long[0]);
    }

    public static String[] convert(Long[] targets) {
        if (targets == null) {
            return new String[0];
        }

        List<String> list = new ArrayList<String>();
        for (Long target : targets) {
            list.add(target.toString());
        }
        return list.toArray(new String[0]);
    }

    public static String toString(Integer val) {
        if (val == null) {
            return "";
        }
        return String.valueOf(val);
    }

    public static String toString(Date date, SimpleDateFormat sdf) {
        if (date == null) {
            return "";
        }
        return sdf.format(date);
    }

    public static String toString(Long val) {
        if (val == null) {
            return "";
        }
        return String.valueOf(val);
    }

    public static String toString(Number val, DecimalFormat df) {
        if (val == null) {
            return "";
        }
        return df.format(val);
    }
}

Related

  1. convert(long number)
  2. convert(long time)
  3. convert(long value, double[] factors, String[] unites)
  4. convert2long(String date, String format)
  5. convertDate(long datenum)
  6. convertDate(long millisecs)
  7. convertDate(long timestamp)