API載點: https://jar-download.com/artifacts/joda-time/joda-time/2.9.4/source-code

import org.joda.time.Interval;
import org.joda.time.Period;

public class TimeTool {

        public static String longToTime(long time) {
                int tns, thh, tmm, tss;
                tns = (int) time / 1000;
                thh = tns / 3600;
                tmm = (tns % 3600) / 60;
                tss = (tns % 60);

                String format_thh = String.format("%2d", thh).replace(" ", "0");
                String format_tmm = String.format("%2d", tmm).replace(" ", "0");
                String format_tss = String.format("%2d", tss).replace(" ", "0");
                
                return format_thh + ":" + format_tmm + ":" + format_tss;
        }

        public static String longToDate(long time) {
                int tns, tYYYY = 0, tMM = 0, tDD, thh;
                tns = (int) time / 1000;
                thh = tns / 3600;
                tDD = thh/24;
                
                
                String format_tYYYY = String.format("%4d", tYYYY).replace(" ", "0");
                String format_tMM = String.format("%2d", tMM).replace(" ", "0");
                String format_tDD = String.format("%2d", tDD).replace(" ", "0");
                
                return format_tYYYY + "-" + format_tMM + "-" + format_tDD;
        }

        public static String longToDateTime(long time) {

                return null;
        }

        public static String dateToLong() {

                return null;
        }

        public static String timeToLong() {

                return null;
        }

        public static String datetimeToLong() {

                return null;
        }

        public static String datetimeToTime() {

                return null;
        }

        public static String datetimeToDate() {

                return null;
        }

        public static String countDate(Date startTime, Date endTime) {
                Interval interval = new Interval(startTime.getTime(), endTime.getTime());
                Period period = interval.toPeriod();

                String format_thh = String.format("%2d", period.getHours()).replace(" ", "0");
                String format_tmm = String.format("%2d", period.getMinutes()).replace(" ", "0");
                String format_tss = String.format("%2d", period.getSeconds()).replace(" ", "0");

                return format_thh + ":" + format_tmm + ":" + format_tss;
        }
        
        public static String getSystemTime() {
                SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");

                return sdf.format(new Date());
        }
        
        public static String getSystemDateTime() {
                SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd hh:mm:ss");
                
                return sdf.format(new Date());
        }
        
        public static void main(String[] args) {
                System.out.println(longToTime(1000002551));
                System.out.println(longToDate(1000110110));
                System.out.println(longToDateTime(0101010110));
                System.out.println(dateToLong());
                System.out.println(timeToLong());
                System.out.println(datetimeToLong());
                System.out.println(datetimeToTime());
                System.out.println(datetimeToDate());
                System.out.println(getSystemDateTime());
        }
}


Kingkazma 發表在 痞客邦 留言(0) 人氣()

public class MessagePane extends JPanel {

        private static final long serialVersionUID = 1L;
        
        @Override
        protected void paintComponent(final Graphics g) {
                final Graphics2D graphics2D = (Graphics2D) g;
                RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
                qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
                graphics2D.setRenderingHints(qualityHints);
                graphics2D.setPaint(Color.ORANGE);
                int width = getWidth();
                int height = getHeight();
                GeneralPath path = new GeneralPath();
                path.moveTo(0, 0);
                path.lineTo(width, 0);
                path.lineTo(width, height-10);
                path.lineTo(width / 2 + 5, height-10);
                path.lineTo(width / 2, height);
                path.lineTo(width / 2 - 5, height-10);
                path.lineTo(0, height - 10);
                path.closePath();
                graphics2D.fill(path);
                
        }
        
        public static void main(String[] args) {
                JWindow f = new JWindow();
                f.setSize(100, 107);
                f.setLocationRelativeTo(null);
                MessagePane panel = new MessagePane();
                f.add(panel);

                f.setBackground(new Color(0, 0, 0, 0));
                f.setVisible(true);
        }
}
}
文章標籤

Kingkazma 發表在 痞客邦 留言(0) 人氣()

 

ctrl+shift+O-->將package自動引用及移除

文章標籤

Kingkazma 發表在 痞客邦 留言(0) 人氣()

1.建立資料庫
    create database 資料庫名稱;

文章標籤

Kingkazma 發表在 痞客邦 留言(0) 人氣()