php教程 PHP源码 Java는 html 영구 달력을 생성합니다.

Java는 html 영구 달력을 생성합니다.

Nov 11, 2016 am 10:52 AM

package Str;  
   
import java.util.Calendar;  
/** 
 *  
 *  
 * @project Tool 
 * @type Test8 
 * @Description  
 * @author xuyw 
 * @email xyw10000@163.com 
 * @date 2014-8-9 下午01:45:02 
 * @version 1.0 
 * 
 */ 
public class Test8 {  
   
    /** 
     * @param args 
     */ 
    public static void main(String[] args) {  
        Calendar calendar = Calendar.getInstance();  
        calendar.add(Calendar.MONTH, 0);  
        calendar.set(Calendar.DAY_OF_MONTH, 1);// 设置为1号,当前日期既为本月第一天  
        int firstDay = calendar.get(Calendar.DAY_OF_WEEK) - 1;  
        int monthDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);// 当月最后一天  
   
        StringBuilder sbd = new StringBuilder();  
        sbd.append("<table cellspacing=&#39;0&#39; style=&#39;background: url(./img/body.png);&#39;>");  
        sbd.append("<thead><tr>");  
        sbd  
                .append("<th>星期天</th><th>星期一</th><th>星期二</th><th>星期三</th><th>星期四</th><th>星期五</th><th>星期六</th>");  
        sbd.append("</tr></thead>");  
        sbd.append("<tbody><tr>");  
        // 第一行  
        int weekend = 0;// 每周的最后一天的日期  
        for (int i = 0; i < 7; i++) {  
            if (i < firstDay) {  
                sbd.append("<td></td>");  
            } else {  
                sbd.append("<td>" + (i - firstDay + 1) + "</td>");  
            }  
            weekend = i - firstDay + 1;  
        }  
        sbd.append("</tr>");  
        while (weekend < monthDays) {  
            sbd.append("<tr>");  
   
            for (int i = 0; i < 7; i++) {  
                if (weekend + i < monthDays)// 数字小于等于当前月的最后一天  
                {  
                    sbd.append("<td>" + (i + weekend + 1) + "</td>");  
                } else {  
                    sbd.append("<td></td>");  
                }  
   
            }  
            sbd.append("</tr>");  
            weekend += 7;// 周末再加7天  
        }  
   
        sbd.append("<tbody></table>");  
        System.out.println(sbd.toString());  
    }  
}
로그인 후 복사

이전 테스트에서는 콘솔을 사용하여 html 태그를 생성했습니다. 생성된 html 태그를 페이지에 표시할 수 있으며 효과는 다음과 같습니다.

Java는 html 영구 달력을 생성합니다.

CSS

* { 
    /* old-style reset here :) */ 
    border: 0px; 
    padding: 0px; 
} 
body { 
    font-family: Helvetica; 
    background: white; 
    text-align: center; 
    /* background: url(../img/body.png) repeat-x; */} 
body h1 { 
    padding-top: 20px; 
    font-size: 36px; 
    color: #335; 
} 
p{font-size:26px;} 
table { 
    border-collapse: separate; 
    border: 1px solid #9DABCE; 
    border-width: 1px 1px 1px 1px; 
    margin: 10px auto; 
    font-size: 30px; 
} 
   
   
td, th { 
    width: 81px; 
    height: 81px; 
    text-align: center; 
    vertical-align: middle; 
    /*background: url(../img/cells.png);*/ 
    color: #444; 
    position: relative; 
} 
th { 
    height: 30px; 
    font-weight: bold; 
    font-size: 14px; 
} 
   
td.sign_in { 
    background-position: 81px 0px; 
    color: red; 
} 
   
td.sign_no{ 
    background: url(../img/cells.png); 
}
로그인 후 복사


본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)