Java SQL Time getSGWDateTime(long dateTime)

Here you can find the source of getSGWDateTime(long dateTime)

Description

get SGW Date Time

License

Apache License

Declaration

public static String getSGWDateTime(long dateTime) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String C_TIME_PATTON_DEFAULT = "yyyy-MM-dd HH:mm:ss";
    public static final String C_DATE_PATTON_DEFAULT = "yyyy-MM-dd";

    public static String getSGWDateTime(long dateTime) {

        dateTime = dateTime * 1000;//  w ww  . j av  a 2 s .  com
        long sd = (dateTime - 28800000);

        Date dat = new Date(sd);
        return formatTime(dat);
    }

    public static String formatTime(Date aTs_Datetime) {
        return format(aTs_Datetime, C_TIME_PATTON_DEFAULT);
    }

    /**
     * @param aTs_Datetime
     * @param as_Format
     * @return
     */
    public static String formatTime(Date aTs_Datetime, String as_Format) {
        if (aTs_Datetime == null || as_Format == null)
            return null;
        SimpleDateFormat dateFromat = new SimpleDateFormat();
        dateFromat.applyPattern(as_Format);

        return dateFromat.format(aTs_Datetime);
    }

    public static String format(Date aTs_Datetime) {
        return format(aTs_Datetime, C_DATE_PATTON_DEFAULT);
    }

    public static String format(Date aTs_Datetime, String as_Pattern) {
        if (aTs_Datetime == null || as_Pattern == null)
            return null;
        SimpleDateFormat dateFromat = new SimpleDateFormat();
        dateFromat.applyPattern(as_Pattern);

        return dateFromat.format(aTs_Datetime);
    }

    /**
     * @param aTs_Datetime
     * @param as_Pattern
     * @return
     */
    public static String format(Timestamp aTs_Datetime, String as_Pattern) {
        if (aTs_Datetime == null || as_Pattern == null)
            return null;
        SimpleDateFormat dateFromat = new SimpleDateFormat();
        dateFromat.applyPattern(as_Pattern);

        return dateFromat.format(aTs_Datetime);
    }
}

Related

  1. getLastTimeOfDay(Calendar calendar)
  2. getMaxModifyTime(String path)
  3. getMaxPollTime(final Connection jdbcConnection, final String tableName)
  4. getServerTime()
  5. getServerTimezone(Properties dbSettings)
  6. getSQLDate(long datetime)
  7. getSQLDateTime()
  8. getZeroTimeDate(Date fecha)
  9. isBetweenHours(Time hora, Time horaInicio, Time horaFim)