Java Unix Date getUnixTime2NoneTime(String longTime)

Here you can find the source of getUnixTime2NoneTime(String longTime)

Description

get Unix Time None Time

License

Open Source License

Declaration

public static String getUnixTime2NoneTime(String longTime) 

Method Source Code

//package com.java2s;

import java.text.FieldPosition;
import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static String getUnixTime2NoneTime(String longTime) {
        String fileseparator = System.getProperty("file.separator");
        int len = longTime.length();
        long ltime = 0;
        if (len > 13) {
            longTime = longTime.substring(0, 13);
        }//from   w  w w  .j  av a 2 s  .  c  o  m
        ltime = Long.parseLong(longTime);
        Date date = new Date();
        date.setTime(ltime);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        String yyyyMMdd = Integer.toString(calendar.get(Calendar.YEAR)) + fileseparator;
        yyyyMMdd += getDateFomrmat(Integer.toString(calendar.get(Calendar.MONTH) + 1));
        yyyyMMdd += getDateFomrmat(Integer.toString(calendar.get(Calendar.DATE)));
        return yyyyMMdd;
    }

    public static String getDateFomrmat(String str) {
        int _input = Integer.parseInt(str);
        StringBuffer result = new StringBuffer();
        DecimalFormat df = new DecimalFormat("00");
        df.format(_input, result, new FieldPosition(1));
        return result.toString();
    }
}

Related

  1. getUnixDate()
  2. getUnixDate(Date date)
  3. getUnixDate(long millis)
  4. getUnixDate(String s)
  5. getUnixTime(String dateTime)
  6. parseUnixDate(String paramName, String dateStr)
  7. stringUnixTime(String start, String end)
  8. toUnixTime(Date date)
  9. toUnixTime(SimpleDateFormat simpleDateFormat, String audioboxDate)