老黄历sdk接口实现及代码示例

合集下载

用java实现简单的万年历输出的代码

用java实现简单的万年历输出的代码

package clock;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;public class Lunar {private int year;private int month;private int day;private boolean leap;final static String chineseNumber[] = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"};static SimpleDateFormat chineseDateFormat = new SimpleDateFormat("yyyy年MM月dd 日");final static long[] lunarInfo = new long[]{0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977,0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950,0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557,0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0,0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0,0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0, 0x195a6,0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570,0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0,0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5,0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930,0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530,0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520,0x0dd45,0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0};//====== 传回农历y年的总天数final private static int yearDays(int y) {int i, sum = 348;for (i = 0x8000; i > 0x8; i >>= 1) {if ((lunarInfo[y - 1900] & i) != 0) sum += 1;}return (sum + leapDays(y));}//====== 传回农历y年闰月的天数final private static int leapDays(int y) {if (leapMonth(y) != 0) {if ((lunarInfo[y - 1900] & 0x10000) != 0)return 30;elsereturn 29;} elsereturn 0;}//====== 传回农历y年闰哪个月1-12 , 没闰传回0final private static int leapMonth(int y) {return (int) (lunarInfo[y - 1900] & 0xf);}//====== 传回农历y年m月的总天数final private static int monthDays(int y, int m) {if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0)return 29;elsereturn 30;}//====== 传回农历y年的生肖final public String animalsYear() {final String[] Animals = new String[]{"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"};return Animals[(year - 4) % 12];}//====== 传入月日的offset 传回干支, 0=甲子final private static String cyclicalm(int num) {final String[] Gan = new String[]{"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};final String[] Zhi = new String[]{"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};return (Gan[num % 10] + Zhi[num % 12]);}//====== 传入offset 传回干支, 0=甲子final public String cyclical() {int num = year - 1900 + 36;return (cyclicalm(num));}/** *//*** 传出y年m月d日对应的农历.* yearCyl3:农历年与1864的相差数?* monCyl4:从1900年1月31日以来,闰月数* dayCyl5:与1900年1月31日相差的天数,再加40 ?* @param cal* @return*/public Lunar(Calendar cal) {@SuppressWarnings("unused") int yearCyl, monCyl, dayCyl;int leapMonth = 0;Date baseDate = null;try {baseDate = chineseDateFormat.parse("1900年1月31日");} catch (ParseException e) {e.printStackTrace(); //To change body of catch statement use Options | File Templates.}//求出和1900年1月31日相差的天数int offset = (int) ((cal.getTime().getTime() - baseDate.getTime()) / 86400000L);dayCyl = offset + 40;monCyl = 14;//用offset减去每农历年的天数// 计算当天是农历第几天//i最终结果是农历的年份//offset是当年的第几天In用java实现简单的万年历输出的代码(2009-12-14 19:08:55)转载标签:分类:计算机类itimport java.util.Scanner;public class Zuizhong{public static void main(String[] args){Scanner input=new Scanner(System.in);System.out.println("--------------------------欢迎使用万年历程序----------------------"); System.out.print("请输入年份:");int year=input.nextInt();System.out.print("\n请输入月份:");int month=input.nextInt();//打印换行符System.out.println();//计算1900年1月1日到指定年份前一年的天数int totalDays=0;//判断是否是1900后的年份if(year>=1900){for(int i=1900;i<year;i++){//判断是否闰年,闰年加366天,否则加365天if((i%4==0 && i%100!=0)||(i%400==0))totalDays+=366;else totalDays+=365;}//计算指定年份1月到指定月份1号之间的天数int daysOfMonth=0;int days;for(int i=1;i<month;i++){switch(i){case 2:if((year%4==0 && year%100!=0)|| year%400==0) days=29;else days=28;break;case 4:case 6:case 9:case 11:days=30;break;default:days=31;}daysOfMonth+=days;}//获得指定年月的天数switch(month){case 2:if((year%4==0 && year%100!=0)|| year%400==0) days=29;else days=28;break;case 4:case 6:case 9:case 11:days=30;break;default:days=31;}//1900.1.1到指定年月1号之间的总天数totalDays+=daysOfMonth;//计算指定年月1号的星期数int firstDay=(totalDays)%7+1;//上一行算出的星期数是1到7,因此要转换成0-6,即星期日=0if(firstDay==7)firstDay=0;//显示月历System.out.println("星期日\t星期一\t星期二\t星期三\t星期四\t星期五\t星期六");//打印1号之前的空格for(int i=0;i<firstDay;i++)System.out.print("\t");//打印月历for(int i=1;i<=days;i++){System.out.print(i+"\t");//如果是星期六,换行if((i-1)%7+firstDay==6)System.out.println();}}else if(year>0&&year<1900){for(int i=1899;i>year;i--){//判断是否闰年,闰年加366天,否则加365天if((i%4==0 && i%100!=0)||(i%400==0))totalDays+=366;else totalDays+=365;}//计算指定年份12月到指定月份31号之后的天数int daysOfMonth=0;int days;for(int i=12;i>=month;i--){switch(i){case 2:if((year%4==0 && year%100!=0)|| year%400==0) days=29;else days=28;break;case 4:case 6:case 9:case 11:days=30;break;default:days=31;}daysOfMonth+=days;}//获得指定年月的天数switch(month){case 2:if((year%4==0 && year%100!=0)|| year%400==0) days=29;else days=28;break;case 4:case 6:case 9:case 11:days=30;break;default:days=31;}//1900.1.1到指定年月1号之间的总天数totalDays+=daysOfMonth;//计算指定年月1号的星期数int firstDay=8-(totalDays)%7;//上一行算出的星期数是1到7,因此要转换成0-6,即星期日=0if(firstDay==7)firstDay=0;if(firstDay==8)firstDay=1;//显示月历System.out.println("星期日\t星期一\t星期二\t星期三\t星期四\t星期五\t星期六");//打印1号之前的空格for(int i=0;i<firstDay;i++)System.out.print("\t");//打印月历for(int i=1;i<=days;i++){System.out.print(i+"\t");//如果是星期六,换行if((i-1)%7+firstDay==6)System.out.println();}}System.out.println("\n程序结束");}}(完)在myeclipse运行效果图:--------------------------欢迎使用万年历程序---------------------- 请输入年份:2009请输入月份:12星期日星期一星期二星期三星期四星期五星期六1 2 3 4 56 7 8 9 10 11 1213 14 15 16 17 18 1920 21 22 23 24 25 2627 28 29 30 31程序结束。

JAVA课程设计 万年历 源代码

JAVA课程设计 万年历 源代码

测试用例设计:根据 需求文档和功能描述, 设计出能够覆盖所有 功能的测试用例
测试工具:使用JUnit 等测试框架进行单元 测试,使用Selenium 等工具进行UI测试
测试结果分析:根 据测试结果,分析 代码存在的问题, 并进行修改和优化
集成测试:验证各个模块之间的接口是否正确,数据传输是否正常 性能测试:测试系统的响应时间、吞吐量、资源利用率等性能指标
提醒功能:用户可以设置提醒功能,在节日或假期到来之前,系统会自动提醒用户。
删除事件:用户可以删除不 再需要的事件
编辑事件:用户可以对已添加 的事件进行编辑,如修改事件 名称、时间等
添加事件:用户可以在万年历 中添加新的事件,如生日、纪 念日等
查询事件:用户可以查询特定 日期或时间段内的事件,如查
界面显示:万年历界面将显示年、 月、日、星期等信息,用户可以通 过点击相应的按钮来切换日期。
添加标题
添加标题
添加标题
添加标题
系统响应:当用户输入日期后,系统 将根据输入的日期显示相应的万年历 信息,包括年、月、日、星期等信息。
用户操作:用户可以通过点击相应 的按钮来切换日期,系统将根据用 户的操作显示相应的万年历信息。
添加标题
界面设计:简洁明了,易于阅读
添加标题
添加标题
交互性:用户可以选择查看不同日 期的日历信息
功能描述:在万年历中,用户可以选择标注节日和假期,以便于查看和提醒。
节日标注:用户可以在万年历中设置自己喜欢的节日,如春节、中秋节等,系统会自动 标注这些节日。
假期标注:用户可以在万年历中设置自己的假期,如年假、病假等,系统会自动标注这 些假期。
,a click to unlimited possibilities

Java万年历源代码,可显示公历、农历、系统时间、国际时间

Java万年历源代码,可显示公历、农历、系统时间、国际时间

import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.table.DefaultTableModel;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;import java.util.GregorianCalendar;import java.util.Locale;import java.util.TimeZone;public class wannianli extends JFrame implements ActionListener, MouseListener {private Calendar cld = Calendar.getInstance();//获取一个Calendar类的实例对象private String[] astr = { "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" };private DefaultTableModel dtm = new DefaultTableModel(null, astr);private JTable table = new JTable(dtm);private JScrollPane sp = new JScrollPane(table);private JButton bLastYear = new JButton("上一年");private JButton bNextYear = new JButton("下一年");private JButton bLastMonth = new JButton("上月");private JButton bNextMonth = new JButton("下月");private JPanel p1 = new JPanel(); // 设立八个中间容器,装入布局控制日期的按钮模块private JPanel p2 = new JPanel(new GridLayout(3,2));//网格布局private JPanel p3 = new JPanel(new BorderLayout());//边界布局private JPanel p4 = new JPanel(new GridLayout(2,1));private JPanel p5 = new JPanel(new BorderLayout());private JPanel p6 = new JPanel(new GridLayout(2,2));private JPanel p7 = new JPanel(new GridLayout(2,1));private JPanel p8 = new JPanel(new BorderLayout());private JComboBox timeBox = newJComboBox(TimeZone.getAvailableIDs());//对所有支持时区进行迭代,获取所有的id;private JTextField jtfYear = new JTextField(5);// jtfYeaar年份显示输入框private JTextField jtfMonth = new JTextField(2);// jtfMouth月份显示输入框private JTextField timeField=new JTextField();//各城市时间显示框private static JTextArea jta = new JTextArea(10,5);//农历显示区private JScrollPane jsp = new JScrollPane(jta);private JLabel l = new JLabel("花江小精灵:亲!你可以直接输入年月查询.");private JLabel lt = new JLabel();private JLabel ld = new JLabel();private JLabel lu = new JLabel("农历和节气");private JLabel null1=new JLabel();private int lastTime;//private String localTime = null;private String s = null;private SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy年MM月dd 日 hh时mm分ss秒");public wannianli() {super("花江日历过去仅留追忆,未来刚生憧憬,唯有坚守本心,把握今天 ZYT 詹永堂 ");// 框架命名this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 窗口关闭函数this.getContentPane().setLayout(new BorderLayout(9, 10));jta.setLineWrap(true);// 长度大于分配长度时候则换行jta.setFont(new Font("黑体", Font.BOLD, 16));table.setBackground(Color.white);table.setGridColor(Color.pink);// 星期之间的网格线是灰色的table.setBackground(Color.white);table.setColumnSelectionAllowed(true);// 将table中的列设置为可选择的table.setSelectionBackground(Color.pink);// 当选定某一天时背景颜色为黑色table.setSelectionForeground(Color.GREEN);table.setBackground(new Color(184,207, 229));// 日期显示表格为浅蓝色table.setFont(new Font("黑体", Font.BOLD, 24));// 日期数字字体格式table.setRowHeight(26);// 表格的高度table.addMouseListener(this); // 鼠标监听器、lu.setFont(new Font("黑体", Font.BOLD, 22));//农历标签格氏jtfYear.addActionListener(this);// 可输入年份的文本框// 为各个按钮添加监听函数bLastYear.addActionListener(this);bNextYear.addActionListener(this);bLastMonth.addActionListener(this);bNextMonth.addActionListener(this);timeBox.addItemListener(new TimeSelectedChangedListener());// 将按钮添加到Jpane上p1.add(bLastYear);p1.add(jtfYear);// 年份输入文本框p1.add(bNextYear);p1.add(bLastMonth);p1.add(jtfMonth);p1.add(bNextMonth);p3.add(jsp, BorderLayout.SOUTH);p3.add(lu,BorderLayout.CENTER);p3.add(ld, BorderLayout.NORTH);p4.add(lt);p4.add(l);p5.add(p4, BorderLayout.SOUTH);p5.add(sp, BorderLayout.CENTER);p5.add(p1, BorderLayout.NORTH);p6.add(timeBox);p6.add(null1);p6.add(timeField);p8.add(p2,BorderLayout.CENTER);p8.add(p7,BorderLayout.SOUTH);this.getContentPane().add(p3, BorderLayout.EAST);this.getContentPane().add(p5, BorderLayout.CENTER);this.getContentPane().add(p6,BorderLayout.SOUTH);this.getContentPane().add(p8,BorderLayout.WEST);String[] strDate = DateFormat.getDateInstance().format(new Date()) .split("-");// 获取日期cld.set(Integer.parseInt(strDate[0]), Integer.parseInt(strDate[1]) - 1,0);showCalendar(Integer.parseInt(strDate[0]),Integer.parseInt(strDate[1]), cld);jtfMonth.setEditable(false);// 设置月份文本框为不可编辑jtfYear.setText(strDate[0]);jtfMonth.setText(strDate[1]);this.showTextArea(strDate[2]);ld.setFont(new Font("新宋体", Font.BOLD, 24));new Timer(lt).start();new TimeThread().start();this.setBounds(200, 200, 700, 350);this.setResizable(false);this.setVisible(true);}public void showCalendar(int localYear, int localMonth, Calendar cld) {int Days = getDaysOfMonth(localYear, localMonth) +cld.get(Calendar.DAY_OF_WEEK) -2;Object [] ai = new Object[7];lastTime = 0;for (int i = cld.get(Calendar.DAY_OF_WEEK)-1; i <= Days; i++) {ai[i%7] =String.valueOf(i-(cld.get(Calendar.DAY_OF_WEEK)-2));if (i%7 == 6){dtm.addRow(ai);ai = new Object[7];lastTime++;}}dtm.addRow(ai);}public int getDaysOfMonth(int Year, int Month) {//计算各月的天数if(Month==1||Month==3||Month==5||Month==7||Month==8||Month==10||Mont h==12){return 31;}if(Month==4||Month==6||Month==9||Month==11){return 30;}if(Year%4==0&&Year%100!=0||Year%400==0)//闰年{return 29;}else {return 28;}}public void actionPerformed(ActionEvent e)//从界面上获取年月数据{if(e.getSource() == jtfYear || e.getSource() == bLastYear || e.getSource() == bNextYear ||e.getSource() == bLastMonth || e.getSource() == bNextMonth){int m, y;try//控制输入的年份正确,异常控制{if (jtfYear.getText().length() != 4){throw new NumberFormatException();}y = Integer.parseInt(jtfYear.getText());m = Integer.parseInt(jtfMonth.getText());}catch (NumberFormatException ex){JOptionPane.showMessageDialog(this, "请输入4位0-9的数字!", "年份有误", JOptionPane.ERROR_MESSAGE);return;}ld.setText("没有选择日期");for (int i = 0; i < lastTime+1; i++){ dtm.removeRow(0);}if(e.getSource() ==bLastYear){ jtfYear.setText(String.valueOf(--y)); }if(e.getSource() ==bNextYear){jtfYear.setText(String.valueOf(++y)); }if(e.getSource() == bLastMonth){if(m == 1){jtfYear.setText(String.valueOf(--y));m = 12;jtfMonth.setText(String.valueOf(m));}else{jtfMonth.setText(String.valueOf(--m));}}if(e.getSource() == bNextMonth){if(m == 12){jtfYear.setText(String.valueOf(++y));m = 1;jtfMonth.setText(String.valueOf(m));}else{jtfMonth.setText(String.valueOf(++m));}}cld.set(y, m-1, 0);showCalendar(y, m, cld);}}public void mouseClicked(MouseEvent e){jta.setText(null);int r = table.getSelectedRow();int c = table.getSelectedColumn();if (table.getValueAt(r,c) == null){ld.setText("没有选择日期");}else{this.showTextArea(table.getValueAt(r,c));}}private void showTextArea(Object selected){ld.setText(jtfYear.getText()+"年"+jtfMonth.getText()+"月"+selected+"日");}public static void main(String[] args){JFrame.setDefaultLookAndFeelDecorated(true);JDialog.setDefaultLookAndFeelDecorated(true);new wannianli();jta.setText(today());}private void updateTimeText(String timeZoneId) {if(timeZoneId != null){TimeZone timeZone = TimeZone.getTimeZone(timeZoneId);dateFormat.setTimeZone(timeZone);Calendar calendar = Calendar.getInstance();calendar.setTimeZone(timeZone);timeField.setText(dateFormat.format(calendar.getTime()));}else{timeField.setText(null);}}private class TimeSelectedChangedListener implements ItemListener { public void itemStateChanged(ItemEvent e) {if (e.getStateChange()==ItemEvent.SELECTED) {if (e.getItem() instanceof String) {s = e.getItem().toString();}}}}private class TimeThread extends Thread{public void run(){while(true){updateTimeText(s);try{Thread.sleep(100);}catch(InterruptedException e){e.printStackTrace();}}}}class Timer extends Thread //显示系统时间{private JLabel lt;private SimpleDateFormat fy = new SimpleDateFormat(" Gyyyy.MM.dd HH:mm:ss ");public Timer(JLabel lt){this.lt=lt;}public void run(){while(true){try{lt.setText(fy.format(new Date()));this.sleep(500);}catch(InterruptedException ex){ex.printStackTrace();}}}}final private static long[] lunarInfo= new long[] { 0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554,0x056a0, 0x09ad0, 0x055d2, 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0,0x14977, 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, 0x06566,0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, 0x0d4a0, 0x1d8a6, 0x0b550,0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, 0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0,0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0, 0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263,0x0d950, 0x05b57, 0x056a0, 0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0,0x195a6, 0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, 0x04af5,0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0, 0x0c960, 0x0d954, 0x0d4a0,0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9,0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, 0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0,0x0d260, 0x0ea65, 0x0d530, 0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520,0x0dd45, 0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0 };final private static int[] year20 = new int[] { 1, 4, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };final private static int[] year19 = new int[] { 0, 3, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 };final private static int[] year2000 = new int[] { 0, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };public final static String[] nStr1 = new String[] { "", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一","十二" };private final static String[] Gan = new String[] { "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" };private final static String[] Zhi = new String[] { "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥" };private final static String[] Animals = new String[] { "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪" };// 传回农历 y年的总天数final private static int lYearDays(int y) {int i, sum = 348;for (i = 0x8000; i > 0x8; i >>= 1) {if ((lunarInfo[y - 1900] & i) != 0)sum += 1;}return (sum + leapDays(y));}// 传回农历 y年闰月的天数final private static int leapDays(int y) {if (leapMonth(y) != 0) {if ((lunarInfo[y - 1900] & 0x10000) != 0)return 30;elsereturn 29;} elsereturn 0;}// 传回农历 y年闰哪个月 1-12 , 没闰传回 0final private static int leapMonth(int y) {return (int) (lunarInfo[y - 1900] & 0xf);}//传回农历 y年m月的总天数final private static int monthDays(int y, int m) {if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0)return 29;elsereturn 30;}// 传回农历 y年的生肖final public static String AnimalsYear(int y) {return Animals[(y - 4) % 12];}//传入月日的offset 传回干支,0=甲子final private static String cyclicalm(int num) {return (Gan[num % 10] + Zhi[num % 12]);}// 传入 offset 传回干支, 0=甲子final public static String cyclical(int y) {int num = y - 1900 + 36;return (cyclicalm(num));}// 传出农历.year0 .month1 .day2 .yearCyl3 .monCyl4 .dayCyl5 .isLeap6final private long[] Lunar(int y, int m) {long[] nongDate = new long[7];int i = 0, temp = 0, leap = 0;Date baseDate = new GregorianCalendar(1900 + 1900, 1,31).getTime();Date objDate = new GregorianCalendar(y + 1900, m, 1).getTime();long offset = (objDate.getTime() - baseDate.getTime()) / 86400000L;if (y < 2000)offset += year19[m - 1];if (y > 2000)offset += year20[m - 1];if (y == 2000)offset += year2000[m - 1];nongDate[5] = offset + 40;nongDate[4] = 14;for (i = 1900; i < 2050 && offset > 0; i++) {temp = lYearDays(i);offset -= temp;nongDate[4] += 12;}if (offset < 0) {offset += temp;i--;nongDate[4] -= 12;}nongDate[0] = i;nongDate[3] = i - 1864;leap = leapMonth(i); // 闰哪个月nongDate[6] = 0;for (i = 1; i < 13 && offset > 0; i++) {// 闰月if (leap > 0 && i == (leap + 1) && nongDate[6] == 0) { --i;nongDate[6] = 1;temp = leapDays((int) nongDate[0]);} else {temp = monthDays((int) nongDate[0], i);}// 解除闰月if (nongDate[6] == 1 && i == (leap + 1))nongDate[6] = 0;offset -= temp;if (nongDate[6] == 0)nongDate[4]++;}if (offset == 0 && leap > 0 && i == leap + 1) {if (nongDate[6] == 1) {nongDate[6] = 0;} else {nongDate[6] = 1;--i;--nongDate[4];}}if (offset < 0) {offset += temp;--i;--nongDate[4];}nongDate[1] = i;nongDate[2] = offset + 1;return nongDate;}// 传出y年m月d日对应的农历.year0 .month1 .day2 .yearCyl3 .monCyl4 .dayCyl5 .isLeap6final public static long[] calElement(int y, int m, int d) {long[] nongDate = new long[7];int i = 0, temp = 0, leap = 0;Date baseDate = new GregorianCalendar(0 + 1900, 0, 31).getTime();Date objDate = new GregorianCalendar(y, m - 1, d).getTime();long offset = (objDate.getTime() - baseDate.getTime()) / 86400000L;nongDate[5] = offset + 40;nongDate[4] = 14;for (i = 1900; i < 2050 && offset > 0; i++) {temp = lYearDays(i);offset -= temp;nongDate[4] += 12;}if (offset < 0) {offset += temp;i--;nongDate[4] -= 12;}nongDate[0] = i;nongDate[3] = i - 1864;leap = leapMonth(i); // 闰哪个月nongDate[6] = 0;for (i = 1; i < 13 && offset > 0; i++) {// 闰月if (leap > 0 && i == (leap + 1) && nongDate[6] == 0) { --i;nongDate[6] = 1;temp = leapDays((int) nongDate[0]);} else {temp = monthDays((int) nongDate[0], i);}// 解除闰月if (nongDate[6] == 1 && i == (leap + 1))nongDate[6] = 0;offset -= temp;if (nongDate[6] == 0)nongDate[4]++;}if (offset == 0 && leap > 0 && i == leap + 1) { if (nongDate[6] == 1) {nongDate[6] = 0;} else {nongDate[6] = 1;--i;--nongDate[4];}}if (offset < 0) {offset += temp;--i;--nongDate[4];}nongDate[1] = i;nongDate[2] = offset + 1;return nongDate;}public final static String getChinaDate(int day) { String a = "";if (day == 10)return"初十";if (day == 20)return"二十";if (day == 30)return"三十";int two = (int) ((day) / 10);if (two == 0)a = "初";if (two == 1)a = "十";if (two == 2)a = "廿";if (two == 3)a = "三";int one = (int) (day % 10);switch (one) {case 1:a += "一";break;case 2:a += "二";break;case 3:a += "三";break;case 4:a += "四";break;case 5:a += "五";break;case 6:a += "六";break;case 7:a += "七";break;case 8:a += "八";break;case 9:a += "九";break;}return a;}public static String today() {Calendar today = Calendar.getInstance(Locale.SIMPLIFIED_CHINESE);int year = today.get(Calendar.YEAR);int month = today.get(Calendar.MONTH) + 1;int date = today.get(Calendar.DATE);long[] l = calElement(year, month, date);StringBuffer sToday = new StringBuffer();try {sToday.append(sdf.format(today.getTime()));sToday.append(" \n");sToday.append(" \n");sToday.append(" \n");sToday.append(" 农历");sToday.append(cyclical(year));sToday.append('(');sToday.append(AnimalsYear(year));sToday.append(")年");sToday.append(" \n");sToday.append(" ");sToday.append(nStr1[(int) l[1]]);sToday.append("月");sToday.append(getChinaDate((int) (l[2])));return sToday.toString();} finally {sToday = null;}}private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy 年M月d日 EEEEE");public void mouseEntered(MouseEvent e) {}public void mouseExited(MouseEvent e) {}public void mousePressed(MouseEvent e) {}public void mouseReleased(MouseEvent e) { }}。

SDK 代码

SDK 代码

在header区域显示内容第一步header 店铺全局的头部配置布局信息配置片区显示内容体验<div class="layout grid-m"> 定义通栏样式<div class=" J_TRegion"> 定义片区<div class="box J_TBox"> 内容<?phpecho "你好";echo "<br />"; 换行echo "哈哈";?></div></div></div>第二步一:准备图片素材二:平台建模块三:编写PHP文件即*新建一个模块modules\dz\dz.pnp代码如下<div class="box J_TBOX"><div class="dz"><img src="assets/images/dz/dz.jpg"/></div></div>四:在header中显示cs02\header.pnp插入篮色代码,代码如下<div class="layout grid-m"><div class="j_tregion"><div class="box j_tbox"><?phpecho include_local_module("dz",dz);?></div>五:配置参数cs02\modules\dz\module插入篮色代码<?xml version="1.0" encoding="GBK" standalone="yes"?><module xsi:noNamespaceSchemaLocation="../../module.xsd" xmlns:xsi="/2001/XMLSchema-instance"><id>dz</id><name>店招图</name><file>dz.php</file><thumbnail>assets/images/dz.png</thumbnail><description>店招</description><requiredCache>true</requiredCache><parameters><param name="dztp_01" label="店招图片" description="输入店招图片地址(950px*157px;)" ptype="text" formType="text">assets/images/dz/dz.jpg</param></parameters></module>六:完成PHP语句,实现交互式操作,即返回modules\dz\dz.pnp插入篮色部分<div class="box J_TBox" <?php echo $_MODULE_TOOLBAR ?>><div class="dz"><?phpif($_MODULE[dztp_01]){echo '<img src="'.$_MODULE[dztp_01].'"/>'}else{echo '<img src="assets/images/dz/dz.jpg"/>';}?></div></div>完成上述步骤在平台http://192.168.0.100:8080/cs02/index.htm后加?debug测试图片上出现编辑对话框OK。

梦哈——日历控件.html

梦哈——日历控件.html
style="background-color: #DCDCDC"></td><td>控件的暗文字颜色</td>
<td><input value="#F5F5FA" onchange="WebCalendar.dayBgColor = this.value; this.style.backgroundColor = this.value"
代码:<span class=code>&lt;input name="txt" onfocus="calendar()"&gt;&lt;input type=button
value=calendar onclick="calendar(document.form1.txt)"&gt;</span></fieldset>
Web Calendar ver 2.0 Author: walkingpoison(水晶龙) mail: wayx@ /Expert/TopicView1.asp?id=1264734
<b>Web Calendar 的第二种调用方法:</b>
<input name="txt" onfocus="calendar()"><input type=button value=calendar onclick="calendar(document.form1.txt)"><br><br>
<td><input value="#FFFFFF" onchange="WebCalendar.lightColor = this.value; this.style.backgroundColor = this.value"

基于C#的节假日日历接口调用代码实例

基于C#的节假日日历接口调用代码实例

基于C#的节假日日历接口调用代码实例代码描述:基于C#的节假日日历接口调用代码实例代码平台:聚合数据using System;using System.Collections.Generic;using System.Linq;using System.Text;using ;using System.IO;using ;using System.Diagnostics;using System.Web;//----------------------------------// 万年历调用示例代码-聚合数据// 在线接口文档:/docs/177// 代码中JsonObject类下载地址:/download/gcm32060 21155665/7458439//----------------------------------namespace ConsoleAPI{class Program{static void Main(string[] args){string appkey = "*******************"; //配置您申请的appkey//1.获取当天的详细信息string url1 = "/calendar/day";var parameters1 = new Dictionary<string, string>();parameters1.Add("key", appkey);//你申请的keyparameters1.Add("date", ""); //指定日期,格式为YYYY-MM-DD,如月份和日期小于10,则取个位,如:2012-1-1string result1 = sendPost(url1, parameters1, "get");JsonObject newObj1 = new JsonObject(result1);String errorCode1 = newObj1["error_code"].Value;if(errorCode1 == "0"){Debug.WriteLine("成功");Debug.WriteLine(newObj1);}else{//Debug.WriteLine("失败");Debug.WriteLine(newObj1["error_code"].Value+":"+newObj1 ["reason"].Value);}//2.获取当月近期假期string url2 = "/calendar/month";var parameters2 = new Dictionary<string, string>();parameters2.Add("key", appkey);//你申请的keyparameters2.Add("year-month", ""); //指定月份,格式为YYYY-MM,如月份和日期小于10,则取个位,如:2012-1string result2 = sendPost(url2, parameters2, "get");JsonObject newObj2 = new JsonObject(result2);String errorCode2 = newObj2["error_code"].Value;if(errorCode2 == "0"){Debug.WriteLine("成功");Debug.WriteLine(newObj2);}else{//Debug.WriteLine("失败");Debug.WriteLine(newObj2["error_code"].Value+":"+newObj2 ["reason"].Value);}//3.获取当年的假期列表string url3 = "/calendar/year";var parameters3 = new Dictionary<string, string>();parameters3.Add("key", appkey);//你申请的keyparameters3.Add("year", ""); //指定年份,格式为YYYY,如:2015string result3 = sendPost(url3, parameters3, "get");JsonObject newObj3 = new JsonObject(result3);String errorCode3 = newObj3["error_code"].Value;if(errorCode3 == "0"){Debug.WriteLine("成功");Debug.WriteLine(newObj3);}else{//Debug.WriteLine("失败");Debug.WriteLine(newObj3["error_code"].Value+":"+newObj3 ["reason"].Value);}}/// <summary>/// Http (GET/POST)/// </summary>/// <param name="url">请求URL</param>/// <param name="parameters">请求参数</param>/// <param name="method">请求方法</param>/// <returns>响应内容</returns>static string sendPost(string url, IDictionary<string, string> p arameters, string method){if(method.ToLower() == "post"){HttpWebRequest req = null;HttpWebResponse rsp = null;System.IO.Stream reqStream = null;try{req = (HttpWebRequest)WebRequest.Create(url);req.Method = method;req.KeepAlive = false;req.ProtocolVersion = HttpVersion.Version10;req.Timeout = 5000;req.ContentType = "application/x-www-form-urlencode d;charset=utf-8";byte[] postData = Encoding.UTF8.GetBytes(BuildQuery (parameters, "utf8"));reqStream = req.GetRequestStream();reqStream.Write(postData, 0, postData.Length);rsp = (HttpWebResponse)req.GetResponse();Encoding encoding = Encoding.GetEncoding(rsp.Charac terSet);return GetResponseAsString(rsp, encoding);}catch(Exception ex){return ex.Message;}finally{if(reqStream != null) reqStream.Close();if(rsp != null) rsp.Close();}}else{//创建请求HttpWebRequest request = (HttpWebRequest)WebRequest.Cre ate(url + "?"+ BuildQuery(parameters, "utf8"));//GET请求request.Method = "GET";request.ReadWriteTimeout = 5000;request.ContentType = "text/html;charset=UTF-8";HttpWebResponse response = (HttpWebResponse)request.Get Response();Stream myResponseStream = response.GetResponseStream();StreamReader myStreamReader = new StreamReader(myRespons eStream, Encoding.GetEncoding("utf-8"));//返回内容string retString = myStreamReader.ReadToEnd();return retString;}}/// <summary>/// 组装普通文本请求参数。

基于JAVA的每日宜忌查询API调用代码实例

基于JAVA的每日宜忌查询API调用代码实例
params.put("key",APPKEY);//应用 APPKEY(应用详细页查询) params.put("date","");//日期,格式 2014-09-09
try { result =net(url, params, "GET"); JSONObject object = JSONObject.fromObject(result); if(object.getInt("error_code")==0){ System.out.println(object.get("result")); }else{ System.out.println(object.get("error_code")+":"+object.
strUrl = strUrl+"?"+urlencode(params); } URL url = new URL(strUrl); conn = (HttpURLConnection) url.openConnection(); if(method==null || method.equals("GET")){
get("reason")); }
} catch (Exception e) { e.printStackTrace();
} }
//2.时辰 public static void getRequest2(){
String result =null; String url ="/laohuangli/h";//请求接口地址 Map params = new HashMap();//请求参数

JAVA《万年历系统》课程设计报告附源码

JAVA《万年历系统》课程设计报告附源码

2013-2014学年第二学期《面向对象程序设计》课程设计报告题目:万年历系统专业:计算机科学与技术班级:姓名:学号:指导教师:成绩:计算机与信息工程系2014年6月6日目录1 设计内容及要求 (1)1.1设计内容 (1)1.2设计任务及具体要求 (1)2 概要设计 (2)2.1程序设计思路 (2)2.2 总体程序框图 (3)3 设计过程或程序代码 (4)3.1各个模块的程序流程图及运行界面 (4)3.2对关键代码加以分析说明 (7)4 设计结果与分析 (13)4.1程序调试的结果 (13)4.2程序设计分析 (13)5 小结 (14)致谢 (15)参考文献 (16)源程序 (17)1 设计内容及要求1.1设计内容万年历,实际上就是记录一定时间范围内(比如100年或更多)的具体阳历或阴历的日期的年历,方便有需要的人查询使用。

在我设计的万年历中主要有:(1)使用图形用户界面来查询用用户所需的日期信息,符合日常软件使用规范。

(2)按月份查询,实现了显示查询1901~2100年某月所有日期的阴阳历对照。

(3)并且添加了重大节日与星座等信息,界面采用日常的星期与月份结合的格式,方便查看与使用。

(4)编写万年历的课程设计,是为了使同学们更加了解高级程序设计语言的结构,掌握基本的程序设计过程和技巧,掌握基本的分析问题和利用计算机求解问题的能力,具备初步的高级语言程序设计能力。

为后续各门计算机课程的学习和毕业设计打下坚实基础。

1.2设计任务及具体要求利用JAVA语言编写的万年历系统采用了多种JAVA语句来实现多种功能。

用户可以通过本程序的applet运行界面来查找一整年某月的农历和阳历,可以查找用户所想了解的某一天具体为星期几,并且可以看到一些重大节日的具体时间。

要求:满足设计万年历系统的目的,即当用户查询年份与月份时,系统就要将这一年的某一月份的阴历与阳历全部显示出来,并且附带这一月份的重大节日。

当用户随意改动年份或月份时系统自动显示与星期对应的日期。

SDK使用说明范文

SDK使用说明范文

SDK使用说明范文一、SDK简介SDK(Software Development Kit,软件开发工具包)是一组开发工具和资源的集合,用于帮助开发者创建应用程序。

SDK提供了开发所需的应用程序接口(API)、示例代码、文档等。

SDK可以大大简化开发过程,提高开发效率。

二、SDK的安装和配置2.配置开发环境需要根据开发环境配置SDK。

例如,在Windows上,需要在系统环境变量中设置SDK的路径。

三、SDK的导入在开发工具中导入SDK,可以使用SDK提供的API进行开发。

1.创建新项目打开开发工具,创建一个新项目。

2.导入SDK在项目中添加SDK,可以通过添加依赖库或引入外部库的方式导入。

四、SDK的使用SDK提供了各种功能的API供开发者使用。

以下是一些常见的SDK使用方法。

1.初始化SDK在应用程序的入口处,调用SDK提供的初始化方法,完成SDK的初始化。

可以根据需要进行必要的配置。

2.登录与认证在用户登录模块中,调用SDK提供的登录与认证API,实现用户的身份认证与管理。

3.数据获取与处理使用SDK提供的API,获取所需的数据。

可以进行数据解析、处理与展示等。

4.事件与回调SDK通常提供事件与回调机制,用于处理异步操作或接收SDK返回的数据。

需要注册相应的事件监听器或回调函数。

5.功能扩展与定制SDK通常提供了一些扩展和定制功能的接口,开发者可以根据需要,自定义SDK的功能与行为。

五、SDK的调试与测试在开发过程中,调试和测试是不可或缺的环节。

1.调试开发者可以使用开发工具提供的调试功能,结合SDK的调试日志,来定位和解决开发中的问题。

2.测试开发者可以编写单元测试或集成测试,来验证SDK的使用是否符合预期,并检查各种边际情况下的功能表现。

六、SDK的更新与升级随着软件的发展和需求变化,SDK也需要进行更新和升级。

一般来说,开发者可以通过以下方式更新SDK:1.官方渠道更新开发者可以定期查看官方网站、论坛或邮件列表,了解最新版本的SDK发布信息。

老黄历sdk接口实现及代码示例

老黄历sdk接口实现及代码示例

老黄历sdk接口实现及代码示例老黄历sdk提供老黄历查询,黄历每日吉凶宜忌查询。

接口名称:老黄历sdk接口平台:聚合数据接口地址:/laohuangli/d支持格式:JSON/XML请求方式:HTTP GET/POST请求示例:/laohuangli/d?date=2014-09-11&key=您申请的KEY 老黄历日历sdk接口JSON返回示例:{"reason": "successed","result": {"id": "1657","yangli": "2014-09-11","yinli": "甲午(马)年八月十八","wuxing": "井泉水建执位","chongsha": "冲兔(己卯)煞东","baiji": "乙不栽植千株不长酉不宴客醉坐颠狂","jishen": "官日六仪益後月德合除神玉堂鸣犬","yi": "祭祀出行扫舍馀事勿取","xiongshen": "月建小时土府月刑厌对招摇五离","ji": "诸事不宜"},"error_code": 0}老黄历时辰sdk接口JSON返回示例:{"reason": "successed","result": [{"yangli": "2014-09-11","hours": "1-3","des": " 修造安葬求财见贵嫁娶进人口移徙","yi": "赴任出行","ji": "冲猴煞北时冲甲申地兵三合长生司命"},{"yangli": "2014-09-11","hours": "3-5","des": " 祈福求嗣订婚嫁娶出行求财开市交易安床作灶祭祀","yi": "修造动土","ji": "冲猪煞东时冲丁亥路空日禄明堂"}, {"yangli": "2014-09-11","hours": "5-7","des": " 赴任修造移徙出行词讼祈福求嗣","yi": "求财见贵祭祀酬神","ji": "冲狗煞南时冲丙戍日破"},{"yangli": "2014-09-11","hours": "7-9","des": " 赴任出行修造","yi": "冲马煞南时冲壬午天牢六戊天官福星","ji": "求财见贵祭祀酬神"},{"yangli": "2014-09-11","hours": "9-11","des": " 赴任修造移徙出行词讼祈福求嗣","yi": "冲羊煞东时冲癸未日刑元武太阴国印","ji": "祭祀祈福合脊嫁娶安葬"},{"yangli": "2014-09-11","hours": "11-13","des": " 冲鼠煞北时冲戊子三合大进帝旺贪狼","yi": "祈福求嗣订婚嫁娶出行求财开市交易安床赴任", "ji": "-"},{"yangli": "2014-09-11","hours": "13-15","des": " 冲牛煞西时冲己丑日刑朱雀右弼","yi": "见贵求财嫁娶进人口移徙安葬","ji": "赴任出行朱雀须用凤凰符制否则诸事不宜"},{"yangli": "2014-09-11","hours": "15-17","des": " 冲虎煞南时冲庚寅天兵喜神金匮左辅","yi": "祈福求嗣订婚嫁娶出行求财开市交易安床赴任见贵", "ji": "上梁盖屋入殓"},{"yangli": "2014-09-11","hours": "17-19","des": " 冲兔煞东时冲辛卯狗食天赦贵人宝光","yi": "修造入宅安葬出行求财见贵订婚嫁娶","ji": "祭祀祈福斋醮酬神"},{"yangli": "2014-09-11","hours": "19-21","des": " 冲龙煞北时冲壬辰日建六戊白虎武曲", "yi": "祭祀斋醮订婚嫁娶出行安葬","ji": "造船乘船祈福求嗣白虎须用麒麟符制否则诸事不宜"},{"yangli": "2014-09-11","hours": "21-23","des": " 冲蛇煞西时冲癸已大退玉堂贵人少微","yi": "盖屋移徙安床入宅开市开仓祭祀祈福酬神出行求财见贵订婚嫁娶","ji": "开光修造安葬"},{"yangli": "2014-09-11","hours": "23-1","des": " 祭祀祈福斋醮开光赴任出行","yi": "求财见贵订婚嫁娶入宅开市安葬修造盖屋移徙作灶安床","ji": "冲鸡煞西时冲乙酉勾陈天地"}],"error_code": 0}。

java调用sdk接口实例

java调用sdk接口实例

调用 SDK 接口的实例通常取决于你正在使用的 SDK 和你想要实现的功能。

以下是一个通用的 Java 调用 SDK 接口的示例:
```java
import com.example.sdk.SDK;
public class SDKExample {
public static void main(String[] args) {
// 初始化 SDK
SDK sdk = new SDK();
// 调用 SDK 的某个方法
String result = sdk.someMethod("input");
// 处理结果
System.out.println(result);
}
}
```
在这个示例中,我们首先导入了 SDK 的类,然后创建了一个 SDK
对象。

然后,我们调用了 SDK 的 `someMethod` 方法,并传递了一个输入参数。

最后,我们处理了该方法的返回结果,并将其打印到控制台上。

请注意,这只是一个示例,具体的实现方式取决于你正在使用的SDK 和你想要实现的功能。

你需要查阅 SDK 的文档或示例代码,以了解如何正确地调用 SDK 接口。

用Java程序编写万年历程序的设计报告

用Java程序编写万年历程序的设计报告

用Java程序编写万年历程序的设计报告一、引言万年历是一种常见的工具,用于显示特定日期的星期几、农历日期、节气等信息。

本设计报告旨在介绍使用Java编写万年历程序的设计过程和实现细节。

二、需求分析1. 显示当前日期的星期几和农历日期;2. 支持用户输入指定日期,显示该日期的星期几和农历日期;3. 显示当月的日历,并标记当天;4. 支持用户选择不同年份和月份,显示相应的日历;5. 显示当天的节气。

三、设计思路1. 日期计算:使用Java提供的日期和时间类,如`java.util.Calendar`,来进行日期计算和格式化;2. 农历计算:根据农历算法,计算指定日期的农历日期和节气;3. 用户界面:使用Java图形用户界面(GUI)库,如`javax.swing`,来实现用户界面;4. 数据展示:使用文本框、标签等组件来展示日期、星期几、农历日期和节气。

四、程序实现1. 创建Java项目,并导入所需的库;2. 创建主界面窗口,设置布局和组件;3. 添加日期选择器,用于选择年份和月份;4. 添加按钮,用于触发日期查询和切换月份;5. 根据用户选择的日期,计算并显示星期几、农历日期和节气;6. 根据用户选择的年份和月份,计算并显示当月的日历;7. 标记当天的日期;8. 添加事件监听器,处理用户的操作。

五、代码示例```java// 导入所需的库import java.util.Calendar;import java.util.Date;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;public class CalendarProgram extends JFrame {private JLabel dateLabel;private JLabel weekdayLabel;private JLabel lunarLabel;private JLabel festivalLabel;private JPanel calendarPanel;public CalendarProgram() {// 设置窗口标题和大小setTitle("万年历程序");setSize(800, 600);// 创建主界面布局和组件JPanel mainPanel = new JPanel(); dateLabel = new JLabel();weekdayLabel = new JLabel(); lunarLabel = new JLabel();festivalLabel = new JLabel();calendarPanel = new JPanel();// 将组件添加到主界面布局中 mainPanel.add(dateLabel);mainPanel.add(weekdayLabel); mainPanel.add(lunarLabel);mainPanel.add(festivalLabel);mainPanel.add(calendarPanel); // 设置主界面布局和显示setContentPane(mainPanel);setVisible(true);}public void updateCalendar(Date selectedDate) {// 根据选择的日期更新界面显示Calendar calendar = Calendar.getInstance();calendar.setTime(selectedDate);// 计算并显示星期几、农历日期和节气int weekday = calendar.get(Calendar.DAY_OF_WEEK); String lunarDate = calculateLunarDate(calendar);String festival = calculateFestival(calendar);dateLabel.setText("日期:" + selectedDate.toString()); weekdayLabel.setText("星期几:" + weekday);lunarLabel.setText("农历日期:" + lunarDate);festivalLabel.setText("节气:" + festival);// 计算并显示当月的日历int year = calendar.get(Calendar.YEAR);int month = calendar.get(Calendar.MONTH);int daysInMonth = calculateDaysInMonth(year, month); displayCalendar(year, month, daysInMonth);}private String calculateLunarDate(Calendar calendar) {// 根据农历算法计算农历日期// 实现略}private String calculateFestival(Calendar calendar) {// 根据日期计算节气// 实现略}private int calculateDaysInMonth(int year, int month) {// 计算指定年份和月份的天数// 实现略}private void displayCalendar(int year, int month, int daysInMonth) { // 显示当月的日历// 实现略}public static void main(String[] args) {CalendarProgram program = new CalendarProgram();program.updateCalendar(new Date());}}```六、总结通过使用Java编写万年历程序,我们可以实现日期计算、农历计算和节气计算等功能,并通过图形界面展示给用户。

基于php的老黄历网开放api调用代码实例

基于php的老黄历网开放api调用代码实例

基于php的老黄历网开放api调用代码实例代码描述:基于php的老黄历网开放api调用代码实例代码平台:聚合数据<!--?php// +----------------------------------------------------------------------// | JuhePHP [ NO ZUO NO DIE ]// +----------------------------------------------------------------------// | Copyright (c) 2010-2015 All rights reserved.// +----------------------------------------------------------------------// | Author: Juhedata <info@-->// +----------------------------------------------------------------------//----------------------------------// 老黄历调用示例代码-聚合数据// 在线接口文档:/docs/65//----------------------------------header('Content-type:text/html;charset=utf-8');//配置您申请的appkey$appkey= "*********************";//************1.日历************$url= "/laohuangli/d";$params= array("key"=> $appkey,//应用APPKEY(应用详细页查询)"date"=>"",//日期,格式2014-09-09);$paramstring= http_build_query($params);$content= juhecurl($url,$paramstring);$result= json_decode($content,true);if($result){if($result['error_code']=='0'){print_r($result);}else{echo$result['error_code'].":".$result['reason'];}}else{echo"请求失败";}//**************************************************//************2.时辰************$url= "/laohuangli/h";$params= array("key"=> $appkey,//应用APPKEY(应用详细页查询)"date"=>"",//日期,格式2014-09-09);$paramstring= http_build_query($params);$content= juhecurl($url,$paramstring);$result= json_decode($content,true);if($result){if($result['error_code']=='0'){print_r($result);}else{echo$result['error_code'].":".$result['reason'];}}else{echo"请求失败";}//**************************************************/*** 请求接口返回内容* @param string $url[请求的URL地址]* @param string $params[请求的参数]* @param int $ipost[是否采用POST形式]* @return string*/functionjuhecurl($url,$params=false,$ispost=0){$httpInfo= array();$ch= curl_init();curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_ 1 );curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData');curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );curl_setopt( $ch, CURLOPT_TIMEOUT , 60);curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);if( $ispost){curl_setopt( $ch, CURLOPT_POST , true );curl_setopt( $ch, CURLOPT_POSTFIELDS , $params);curl_setopt( $ch, CURLOPT_URL , $url);}else{if($params){curl_setopt( $ch, CURLOPT_URL , $url.'?'.$par ams);}else{curl_setopt( $ch, CURLOPT_URL , $url);}}$response= curl_exec( $ch);if($response=== FALSE) {//echo "cURL Error: " . curl_error($ch);returnfalse;}$httpCode= curl_getinfo( $ch, CURLINFO_HTTP_CODE );$httpInfo= array_merge( $httpInfo, curl_getinfo( $ch) );curl_close( $ch);return$response;}。

js实现带农历和八字等信息的日历特效_

js实现带农历和八字等信息的日历特效_

js实现带农历和八字等信息的日历特效_ 本文主要介绍了js实现带农历和八字等信息的日历特效,我觉得挺不错的,现在分享给大家,也给大家做个参考自己也尝试着做了一下,收获蛮大,把握了js日历特效的实现原理后,再想增加更多的功能,完全就可以自由发挥了,先在这里分享一下吧,有爱好的可以试试!本文实例为大家分享了js实现带农历等信息的日历特效,代码量很大,供大家参考,具体内容如下效果图:实现代码:代码如下:HTMLHEADTITLE万年历/TITLEMETA content="农历; 阳历; 月历; 节日; 时区; 节气; 八字; 干支; 生肖; gregorian solar; chinese lunar; calendar;" name=keywordsMETA content=All name=robotsMETA content="gregorian solar calendar and chinese lunar calendar" name=descriptionmeta charset="UTF-8"/style type="text/css"body {margin: 0px;padding: 0px;}/style/headbodycenterbrtable cellpadding="0" cellspacing="0" id="1" trtdstyle#cal {width: 434px;border: 1px solid #c3d9ff;font-size: 12px;margin: 8px 0 0 15px;}#cal #top {height: 29px;line-height: 29px; background: #e7eef8; color: #003784;padding-left: 30px; }#cal #top select {font-size: 12px;}#cal #top input {padding: 0;}#cal ul#wk {margin: 0;padding: 0;height: 25px;}#cal ul#wk li {float: left;width: 60px;text-align: center; line-height: 25px; list-style: none;}#cal ul#wk li b {font-weight: normal;color: #c60b02;}#cal #cm {clear: left;border-top: 1px solid #ddd;border-bottom: 1px dotted #ddd; position: relative;}#cal #cm .cell {position: absolute;width: 42px;height: 36px;text-align: center;margin: 0 0 0 9px;}#cal #cm .cell .so {font: bold 16px arial;}#cal #bm {text-align: right;height: 24px;line-height: 24px;padding: 0 13px 0 0;}#cal #bm a {color: 7977ce;}#cal #fd {display: none;position: absolute;border: 1px solid #dddddf; background: #feffcd;padding: 10px;line-height: 21px;width: 150px;}#cal #fd b {font-weight: normal;color: #c60a00;}/style!--[if IE]style#cal #top{padding-top:4px;}#cal #top input{width:65px;}#cal #fd{width:170px;}/style![endif]--div id="cal"div id="top"公元select/select 年select/select月农历span/span年[span/span年]input type="button" value="回到今日" title="点击后跳转回今日" style="padding:0px"/divul id="wk"li一/lili二/lili三/lili四/lili五/lilib六/b/lilib日/b/li/uldiv id="cm"/divdiv id="bm"a target="_blank" onmousedown="returnc({'fm':'alop','title':this.innerHTML,'url':this.href,'p1':al_c(this),'p2':1})"href="javascript:void(0)"历史上的今日/a/div/div/td/tr/table/center/bodyscript language="JavaScript"!--(function() {var S = erAgent.indexOf("MSIE") != -1 !window.opera;function M(C) {return document.getElementById(C)}function R(C) {return document.createElement(C)}var P = [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, 0x04970, 0x0a4b0, 0x0b4b5,0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, 0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, 0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, 0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0, 0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, 0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6, 0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, 0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0, 0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, 0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, 0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, 0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0, 0x14b63];var K = "甲乙丙丁戊己庚辛壬癸";var J = "子丑寅卯辰巳午未申酉戌亥";var O = "鼠牛虎兔龙蛇马羊猴鸡狗猪";var L = ["小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"];var D = [0, 21208, 43467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758];var B = "日一二三四五六七八九十";var H = ["正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"];var E = "初十廿卅";var V = {"0101": "*1元旦节","0214": "情人节","0305": "学雷锋纪念日","0308": "妇女节","0312": "植树节","0315": "消费者权益日","0401": "愚人节","0501": "*1劳动节","0504": "青年节","0601": "国际儿童节","0701": "中国共产党诞辰", "0801": "建军节","0910": "中国老师节","1001": "*3国庆节","1224": "平安夜","1225": "圣诞节"};var T = {"0101": "*2春节","0115": "元宵节","0505": "*1端午节","0815": "*1中秋节","0909": "重阳节","1208": "腊八节","0100": "除夕"};function U(Y) {function c(j, i) {var h = new Date((31556925974.7 * (j - 1900) + D[i] * 60000) + Date.UTC(1900, 0, 6, 2, 5));return (h.getUTCDate())}function d(k) {var h, j = 348;for (h = 32768; h 8; h = 1) {j += (P[k - 1900] h) ? 1 : 0}return (j + b(k))}function a(h) {return (K.charAt(h % 10) + J.charAt(h % 12)) }function b(h) {if (g(h)) {return ((P[h - 1900] 65536) ? 30 : 29)} else {return (0)}}function g(h) {return (P[h - 1900] 15)}function e(i, h) {return ((P[i - 1900] (65536 h)) ? 30 : 29) }function C(m) {var k, j = 0,h = 0;var l = new Date(1900, 0, 31);var n = (m - l) / 86400000;this.dayCyl = n + 40;this.monCyl = 14;for (k = 1900; k 2050 n 0; k++) {h = d(k);n -= h;this.monCyl += 12}if (n 0) {n += h;k--;this.monCyl -= 12}this.year = k;this.yearCyl = k - 1864;j = g(k);this.isLeap = false;for (k = 1; k 13 n 0; k++) {if (j 0 k == (j + 1) this.isLeap == false) { --k;this.isLeap = true;h = b(this.year)} else {h = e(this.year, k)}if (this.isLeap == true k == (j + 1)) {this.isLeap = false}n -= h;if (this.isLeap == false) {this.monCyl++}}if (n == 0 j 0 k == j + 1) {if (this.isLeap) {this.isLeap = false} else {this.isLeap = true;--k;--this.monCyl}}if (n 0) {n += h;--k;--this.monCyl}this.month = k;this.day = n + 1}function G(h) {return h 10 ? "0" + h : h}function f(i, j) {var h = i;return j.replace(/dd?d?d?|MM?M?M?|yy?y?y?/g, function(k) {switch (k) {case "yyyy":var l = "000" + h.getFullYear(); return l.substring(l.length - 4); case "dd":return G(h.getDate());case "d":return h.getDate().toString();case "MM":return G((h.getMonth() + 1));case "M":return h.getMonth() + 1}})}function Z(i, h) {var j;switch (i, h) {case 10:j = "初十";break;case 20:j = "二十";break;case 30:j = "三十";break;default:j = E.charAt(Math.floor(h / 10));j += B.charAt(h % 10)}return (j)}this.date = Y;this.isToday = false;this.isRestDay = false;this.solarYear = f(Y, "yyyy");this.solarMonth = f(Y, "M");this.solarDate = f(Y, "d");this.solarWeekDay = Y.getDay();this.solarWeekDayInChinese = "星期" + B.charAt(this.solarWeekDay);var X = new C(Y);this.lunarYear = X.year;this.shengxiao = O.charAt((this.lunarYear - 4) % 12);this.lunarMonth = X.month;this.lunarIsLeapMonth = X.isLeap;this.lunarMonthInChinese = this.lunarIsLeapMonth ? "闰" + H[X.month - 1] : H[X.month - 1];this.lunarDate = X.day;this.showInLunar = this.lunarDateInChinese = Z(this.lunarMonth, this.lunarDate);if (this.lunarDate == 1) {this.showInLunar = this.lunarMonthInChinese + "月"}this.ganzhiYear = a(X.yearCyl);this.ganzhiMonth = a(X.monCyl);this.ganzhiDate = a(X.dayCyl++);this.jieqi = "";this.restDays = 0;if (c(this.solarYear, (this.solarMonth - 1) * 2) == f(Y, "d")) {this.showInLunar = this.jieqi = L[(this.solarMonth - 1) * 2]}if (c(this.solarYear, (this.solarMonth - 1) * 2 + 1) == f(Y, "d")) {this.showInLunar = this.jieqi = L[(this.solarMonth - 1) * 2 + 1]}if (this.showInLunar == "清明") {this.showInLunar = "清明节";this.restDays = 1}this.solarFestival = V[f(Y, "MM") + f(Y, "dd")]; if (typeof this.solarFestival == "undefined") { this.solarFestival = ""} else {if (/\*(\d)/.test(this.solarFestival)) {this.restDays = parseInt(RegExp.$1);this.solarFestival = this.solarFestival.replace(/\*\d/, "")}}this.showInLunar = (this.solarFestival == "") ? this.showInLunar : this.solarFestival;this.lunarFestival = T[this.lunarIsLeapMonth ? "00" : G(this.lunarMonth) + G(this.lunarDate)];if (typeof this.lunarFestival == "undefined") { this.lunarFestival = ""} else {if (/\*(\d)/.test(this.lunarFestival)) {this.restDays = (this.restDays parseInt(RegExp.$1)) ? this.restDays : parseInt(RegExp.$1);this.lunarFestival = this.lunarFestival.replace(/\*\d/, "")}}if (this.lunarMonth == 12 this.lunarDate == e(this.lunarYear, 12)) {this.lunarFestival = T["0100"];this.restDays = 1}this.showInLunar = (this.lunarFestival == "") ? this.showInLunar : this.lunarFestival;this.showInLunar = (this.showInLunar.length 4) ? this.showInLunar.substr(0, 2) + "..." :this.showInLunar}var Q = (function() {var X = {};X.lines = 0;X.dateArray = new Array(42);function Y(a) {return (((a % 4 === 0) (a % 100 !== 0)) || (a % 400 === 0))}function G(a, b) {return [31, (Y(a) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][b]}function C(a, b) {a.setDate(a.getDate() + b);return a}function Z(a) {var f = 0;var c = new U(new Date(a.solarYear, a.solarMonth - 1, 1));var d = (c.solarWeekDay - 1 == -1) ? 6 : c.solarWeekDay - 1;X.lines = Math.ceil((d + G(a.solarYear, a.solarMonth - 1)) / 7);for (var e = 0; e X.dateArray.length; e++) { if (c.restDays != 0) {f = c.restDays}if (f 0) {c.isRest = true}if (d-- 0 || c.solarMonth != a.solarMonth) { X.dateArray[e] = null;continue}var b = new U(new Date());if (c.solarYear == b.solarYear c.solarMonth ==b.solarMonthc.solarDate == b.solarDate) {c.isToday = true}X.dateArray[e] = c;c = new U(C(c.date, 1));f--}}return {init: function(a) {Z(a)},getJson: function() {return X}}})();var W = (function() {var C = M("top").getElementsByTagName("SELECT")[0];var X = M("top").getElementsByTagName("SELECT")[1];var G = M("top").getElementsByTagName("SPAN")[0]; var c = M("top").getElementsByTagName("SPAN")[1]; var Y = M("top").getElementsByTagName("INPUT")[0]; function a(g) {G.innerHTML = g.ganzhiYear;c.innerHTML = g.shengxiao}function b(g) {C[g.solarYear - 1901].selected = true;X[g.solarMonth - 1].selected = true}function f() {var j = C.value;var g = X.value;var i = new U(new Date(j, g - 1, 1));Q.init(i);N.draw();if (this == C) {i = new U(new Date(j, 3, 1));G.innerHTML = i.ganzhiYear;c.innerHTML = i.shengxiao}var h = new U(new Date());Y.style.visibility = (j == h.solarYear g == h.solarMonth) ? "hidden" : "visible"}function Z() {var g = new U(new Date());a(g);b(g);Q.init(g);N.draw();Y.style.visibility = "hidden"}function d(k, g) {for (var j = 1901; j 2050; j++) { var h = R("OPTION");h.value = j;h.innerHTML = j;if (j == k) {h.selected = "selected"}C.appendChild(h)}for (var j = 1; j 13; j++) {var h = R("OPTION");h.value = j;h.innerHTML = j;if (j == g) {h.selected = "selected"}X.appendChild(h)}C.onchange = f;X.onchange = f}function e(g) {d(g.solarYear, g.solarMonth);G.innerHTML = g.ganzhiYear;c.innerHTML = g.shengxiao;Y.onclick = Z;Y.style.visibility = "hidden" }return {init: function(g) {e(g)},reset: function(g) {b(g)}}})();var N = (function() {function C() {var Z = Q.getJson();var c = Z.dateArray;M("cm").style.height = Z.lines * 38 + 2 + "px"; M("cm").innerHTML = "";for (var a = 0; a c.length; a++) {if (c[a] == null) {continue}var X = R("DIV");if (c[a].isToday) {X.style.border = "1px solid #a5b9da";X.style.background = "#c1d9ff"}X.className = "cell";X.style.left = (a % 7) * 60 + "px";X.style.top = Math.floor(a / 7) * 38 + 2 + "px"; var b = R("DIV");b.className = "so";b.style.color = ((a % 7) 4 || c[a].isRest) ?"#c60b02" : "#313131";b.innerHTML = c[a].solarDate; X.appendChild(b);var Y = R("DIV");Y.style.color = "#666";Y.innerHTML = c[a].showInLunar; X.appendChild(Y);X.onmouseover = (function(d) { return function(f) {F.show({dateIndex: d,cell: this})}})(a);X.onmouseout = function() {F.hide()};M("cm").appendChild(X)}var G = R("DIV");G.id = "fd";M("cm").appendChild(G);F.init(G)}return {draw: function(G) {C(G)}}})();var F = (function() {var C;function Y(e, c) {if (arguments.length 1) {var b = /([.*+?^=!:${}()|[\]\/\\])/g,Z = "{".replace(b, "\\$1"),d = "}".replace(b, "\\$1");var a = new RegExp("#" + Z + "([^" + Z + d + "]+)" + d, "g");if (typeof(c) == "object") {return e.replace(a, function(f, h) {var g = c[h];return typeof(g) == "undefined" ? "" : g})}}return e}function G(b) {var a = Q.getJson().dateArray[b.dateIndex];var Z = b.cell;var c = "#{solarYear} 年#{solarMonth} 月#{solarDate} 日 #{solarWeekDayInChinese}";c += "brb农历#{lunarMonthInChinese}月#{lunarDateInChinese}/b";c += "br#{ganzhiYear}年#{ganzhiMonth}月#{ganzhiDate}日";if (a.solarFestival != "" || a.lunarFestival != "" || a.jieqi != "") {c += "brb#{lunarFestival} #{solarFestival} #{jieqi}/b"}C.innerHTML = Y(c, a);C.style.top = Z.offsetTop + Z.offsetHeight - 5 + "px";C.style.left = Z.offsetLeft + Z.offsetWidth - 5 + "px";C.style.display = "block"}function X() {C.style.display = "none"}return {show: function(Z) {G(Z)},hide: function() {X()},init: function(Z) {C = Z}}})();var I = (function() {var G = M("bm").getElementsByTagName("A")[0]; function C(X) {G.href = "l以上就是本文的全部内容,盼望对大家学习javascript 程序设计有所关心。

sdk开发案例

sdk开发案例

sdk开发案例SDK(Software Development Kit,软件开发工具包)开发案例主要包括以下几个方面:1. 微信SDK开发:微信SDK提供了一套完善的开发工具和API,使得开发人员可以构建具有微信功能的应用。

例如,开发微信小程序、微信公众号、微信企业号等,实现聊天机器人、朋友圈、微信支付等功能。

2. Android SDK开发:Android SDK是一套用于开发Android手机应用程序的工具和API。

开发者可以使用Android SDK构建各种应用程序,如手机游戏、社交应用、工具应用等。

例如,开发一个天气应用,实现实时天气查询、预警等功能。

3. iOS SDK开发:iOS SDK是苹果公司提供的一套用于开发iOS设备(如iPhone、iPad等)应用程序的工具和API。

开发者可以使用iOS SDK 构建各种应用程序,如手机游戏、社交应用、工具应用等。

例如,开发一个音乐播放器应用,实现音乐播放、歌词显示、歌曲推荐等功能。

4. Node.js SDK开发:Node.js是一个基于JavaScript的服务器端编程框架。

使用Node.js SDK,开发者可以构建高性能、可扩展的服务器和应用程序。

例如,开发一个在线购物网站,实现商品展示、购物车、订单处理等功能。

5. 手游SDK开发:手游SDK主要用于解决游戏中的登录、支付、数据统计等问题。

例如,开发一个手机游戏,实现用户注册、登录、购买道具、游戏排行榜等功能。

6. 音频SDK开发:音频SDK提供了一组用于处理音频数据的API,开发者可以利用这些API构建音乐制作、语音识别、音频处理等应用。

例如,开发一个音频处理工具,实现音频剪辑、混音、均衡等功能。

7. 视频SDK开发:视频SDK提供了一组用于处理视频数据的API,开发者可以利用这些API构建视频播放、剪辑、特效处理等应用。

例如,开发一个视频编辑软件,实现视频剪辑、字幕添加、特效应用等功能。

基于GO的万年历api调用代码实例

基于GO的万年历api调用代码实例

基于GO的万年历api调用代码实例代码描述:基于GO的万年历api调用代码实例代码平台:聚合数据package mainimport("io/ioutil""net/http""net/url""fmt""encoding/json")//----------------------------------// 万年历调用示例代码-聚合数据// 在线接口文档:/docs/177//----------------------------------const APPKEY = "*******************"//您申请的APPKEY func main(){//1.获取当天的详细信息Request1()//2.获取当月近期假期Request2()//3.获取当年的假期列表Request3()}//1.获取当天的详细信息func Request1(){//请求地址juheURL :="/calendar/day"//初始化参数param:=url.Values{}//配置请求参数,方法内部已处理urlencode问题,中文参数可以直接传参param.Set("key",APPKEY) //您申请的appKeyparam.Set("date","") //指定日期,格式为YYYY-MM-DD,如月份和日期小于10,则取个位,如:2012-1-1//发送请求data,err:=Get(juheURL,param)if err!=nil{fmt.Errorf("请求失败,错误信息:\r\n%v",err)}else{var netReturn map[string]interface{}json.Unmarshal(data,&netReturn)if netReturn["error_code"].(float64)==0{fmt.Printf("接口返回result字段是:\r\n%v",netReturn["result "])}}}//2.获取当月近期假期func Request2(){//请求地址juheURL :="/calendar/month"//初始化参数param:=url.Values{}//配置请求参数,方法内部已处理urlencode问题,中文参数可以直接传参param.Set("key",APPKEY) //您申请的appKeyparam.Set("year-month","") //指定月份,格式为YYYY-MM,如月份和日期小于10,则取个位,如:2012-1//发送请求data,err:=Get(juheURL,param)if err!=nil{fmt.Errorf("请求失败,错误信息:\r\n%v",err)}else{var netReturn map[string]interface{}json.Unmarshal(data,&netReturn)if netReturn["error_code"].(float64)==0{fmt.Printf("接口返回result字段是:\r\n%v",netReturn["result "])}}}//3.获取当年的假期列表func Request3(){//请求地址juheURL :="/calendar/year"//初始化参数param:=url.Values{}//配置请求参数,方法内部已处理urlencode问题,中文参数可以直接传参param.Set("key",APPKEY) //您申请的appKeyparam.Set("year","") //指定年份,格式为YYYY,如:2015//发送请求data,err:=Get(juheURL,param)if err!=nil{fmt.Errorf("请求失败,错误信息:\r\n%v",err)}else{var netReturn map[string]interface{}json.Unmarshal(data,&netReturn)if netReturn["error_code"].(float64)==0{fmt.Printf("接口返回result字段是:\r\n%v",netReturn["result "])}}}// get 网络请求func Get(apiURL string,params url.Values)(rs[]byte,err error){ var Url *url.URLUrl,err=url.Parse(apiURL)if err!=nil{fmt.Printf("解析url错误:\r\n%v",err)return nil,err}//如果参数中有中文参数,这个方法会进行URLEncodeUrl.RawQuery=params.Encode()resp,err:=http.Get(Url.String())if err!=nil{fmt.Println("err:",err)return nil,err}defer resp.Body.Close()return ioutil.ReadAll(resp.Body)}// post 网络请求 ,params 是url.Values类型func Post(apiURL string, params url.Values)(rs[]byte,err error){ resp,err:=http.PostForm(apiURL, params)if err!=nil{return nil ,err}defer resp.Body.Close()return ioutil.ReadAll(resp.Body)}。

java万年历思路

java万年历思路

Java万年历思路1. 简介Java万年历是一种用来显示日期信息的工具,可以根据用户输入的年份和月份,生成对应月份的日历,并以美观的方式展示出来。

本文将介绍实现Java万年历的思路和步骤。

2. 思路实现Java万年历的主要思路如下: 1. 获取用户输入的年份和月份; 2. 判断输入是否合法,包括年份范围和月份范围; 3. 根据输入的年份和月份计算该月第一天是星期几; 4. 根据每个月的天数和第一天是星期几,生成一个二维数组表示整个月份的日历; 5. 将生成的日历以表格形式输出。

3. 实现步骤下面将详细介绍每个步骤具体的实现方法。

3.1 获取用户输入使用Java标准库中的Scanner类来获取用户输入。

首先创建一个Scanner对象,并使用其nextInt()方法获取用户输入的年份和月份。

Scanner scanner = new Scanner(System.in);System.out.print("请输入年份:");int year = scanner.nextInt();System.out.print("请输入月份:");int month = scanner.nextInt();3.2 判断输入是否合法要判断用户输入是否合法,需要考虑以下几个方面: - 年份范围:通常情况下,年份应该在公历的范围内,例如从1900年到2099年; - 月份范围:月份应该在1到12之间。

if (year < 1900 || year > 2099) {System.out.println("请输入合法的年份(1900-2099)!");return;}if (month < 1 || month > 12) {System.out.println("请输入合法的月份(1-12)!");return;}3.3 计算第一天是星期几根据输入的年份和月份,可以使用Java标准库中的Calendar类来计算该月第一天是星期几。

饥慌控制台示例代码如何实现简单的日历功能

饥慌控制台示例代码如何实现简单的日历功能

饥慌控制台示例代码如何实现简单的日历功能以下是一个简单的控制台示例代码,演示了如何实现一个基本的日历功能。

代码使用C#语言编写,通过控制台输出日历。

```csharpusing System;namespace CalendarExample{class Program{static void Main(string[] args){// 获取当前日期DateTime today = DateTime.Today;// 输出当前年份和月份Console.WriteLine("Calendar - {0} {1}",today.ToString("MMMM"), today.Year);Console.WriteLine("-----------------------------------------");Console.WriteLine();// 输出日历表头Console.WriteLine("Sun Mon Tue Wed Thu Fri Sat");// 获取当前月份的第一天和最后一天DateTime firstDayOfMonth = new DateTime(today.Year, today.Month, 1);DateTime lastDayOfMonth =firstDayOfMonth.AddMonths(1).AddDays(-1);// 计算当前月份的第一天是星期几DayOfWeek firstDayOfWeek = firstDayOfMonth.DayOfWeek;// 输出日历中的每一天for (int i = 0; i < (int)firstDayOfWeek; i++)Console.Write(" "); // 空格占位,对齐第一天for (DateTime day = firstDayOfMonth; day <= lastDayOfMonth; day = day.AddDays(1)){// 输出每一天的日期Console.Write("{0,2} ", day.Day);// 换行处理if (day.DayOfWeek == DayOfWeek.Saturday)Console.WriteLine();}// 结束程序Console.WriteLine();Console.WriteLine("-----------------------------------------");Console.WriteLine("Press any key to exit...");Console.ReadKey();}}}```这个示例代码实现了一个简单的控制台日历功能。

C语言实现的程序员老黄历实例

C语言实现的程序员老黄历实例

C语⾔实现的程序员⽼黄历实例本⽂实例讲述了C语⾔实现的程序员⽼黄历。

分享给⼤家供⼤家参考。

具体如下:以前看到过⼀个jquery程序员⽼黄历页⾯,觉得挺有创意的,⾃⼰闲着⽤C语⾔也写了⼀个,基本就是随机数的⽣成,没什么难度,⼤家随便看看,⾼⼿请绕过此篇,控制台程序没什么美观可⾔,已经尽量弄得好看点了。

#include <stdio.h>#include <time.h>int random(int dayseed,int indexseed)//根据当前时间“天 ”产⽣伪随机数。

{int i,n;n = dayseed % 11117;for (i = 0; i < 100 + indexseed; i++){n = n * n;n = n % 11117; // 11117 是个质数}return n;}int isWeekend(struct tm *p){return p->tm_wday == 0 || p->tm_wday == 6;}int main(int argc, char *argv[]){char *weeks[6] = {"⼀","⼆","三","四","五","六","⽇"};printf("|-------------------------------------|\n");printf("| 程序员⽼黄历beta 1.0 |\n");printf("|-------------------------------------|\n");time_t timep;struct tm *p;time(&timep);p =localtime(&timep);//此函数获得的tm结构体的时间,是已经进⾏过时区转化为本地时间printf("|-------------------------------------|\n");printf("| 今天是%d年%d⽉%d⽇星期%s |\n",1900+p->tm_year,1+p->tm_mon,p->tm_mday,weeks[p->tm_wday-1]);printf("|-------------------------------------|\n");int randNum=random(p->tm_mday, 2);//产⽣伪随机数int randNum1=random(p->tm_mday, 3);char *activities[27][3] = {{"写单元测试", "写单元测试将减少出错","写单元测试会降低你的开发效率"},{"⽩天上线", "今天⽩天上线是安全的","可能导致灾难性后果"},{"重构", "代码质量得到提⾼","你很有可能会陷⼊泥潭"},{"使⽤%t", "你看起来更有品位","别⼈会觉得你在装逼"},{"跳槽", "该放⼿时就放⼿","鉴于当前的经济形势,你的下⼀份⼯作未必⽐现在强"},{"招⼈", "你遇到千⾥马的可能性⼤⼤增加","你只会招到⼀两个混饭吃的外⾏"},{"⾯试", "⾯试官今天⼼情很好","⾯试官不爽,会拿你出⽓"},{"提交辞职申请", "公司找到了⼀个⽐你更能⼲更便宜的家伙,巴不得你赶快滚蛋","鉴于当前的经济形势,你的下⼀份⼯作未必⽐现在强"},{"申请加薪", "⽼板今天⼼情很好","公司正在考虑裁员"},{"晚上加班", "晚上是程序员精神最好的时候","", },{"命名变量\"%v\"", "",""},{"写超过%l⾏的⽅法", "你的代码组织的很好,长⼀点没关系","你的代码将混乱不堪,你⾃⼰都看不懂"},{"提交代码", "遇到冲突的⼏率是最低的","你遇到的⼀⼤堆冲突会让你觉得⾃⼰是不是时间穿越了"},{"代码复审", "发现重要问题的⼏率⼤⼤增加","你什么问题都发现不了,⽩⽩浪费时间"},{"开会", "写代码之余放松⼀下打个盹,有益健康","你会被扣屎盆⼦背⿊锅"},{"晚上上线", "晚上是程序员精神最好的时候","你⽩天已经筋疲⼒尽了"},{"修复BUG", "你今天对BUG的嗅觉⼤⼤提⾼","新产⽣的BUG将⽐修复的更多"},{"设计评审", "设计评审会议将变成头脑风暴","⼈⼈筋疲⼒尽,评审就这么过了"},{"需求评审", "",""},{"打DOTA", "你将有如神助","你会被虐的很惨", }, //这⾥往下的是周末特定情况(19-27){"洗澡", "你⼏天没洗澡了?","会把设计⽅⾯的灵感洗掉", },{"锻炼⼀下⾝体", "","能量没消耗多少,吃得却更多", },{"抽烟", "抽烟有利于提神,增加思维敏捷","除⾮你活够了,死得早点没关系", },{"在妹⼦⾯前吹⽜", "改善你矮穷挫的形象","会被识破", },{"撸管", "避免缓冲区溢出","强撸灰飞烟灭", },{"浏览成⼈⽹站", "重拾对⽣活的信⼼","你会⼼神不宁", },{"上微博", "今天发⽣的事不能错过","会看到令⼈⼼情不好的事", },{"上AB站", "还需要理由吗?","满屏的兄贵我会说出来?", }};printf("|-------------------------------------|\n");if(isWeekend(p))printf("| 宜: \n| %2s\n| %s\n",activities[19+randNum%8][0],activities[randNum%27][1]);elseprintf("| 宜: \n| %2s\n| %s\n",activities[randNum%17][0],activities[randNum%27][1]);printf("|-------------------------------------|\n");printf("|-------------------------------------|\n");if(isWeekend(p))printf("| 不宜:\n| %s\n| %s\n",activities[19+randNum1%8][0],activities[randNum1%27][2]);elseprintf("| 不宜:\n| %s\n| %s\n",activities[randNum1%17][0],activities[randNum1%27][2]);printf("|-------------------------------------|\n");/*座位朝向*/char *directions[8]= {"北⽅","东北⽅","东⽅","东南⽅","南⽅","西南⽅","西⽅","西北⽅"};printf("|-------------------------------------|\n");printf("| 座位朝向:⾯向 %s 写程序,BUG 最少.\n",directions[randNum%8]);/*今⽇宜饮*/char *drinks[14] = {"⽔","茶","红茶","绿茶","咖啡","奶茶","可乐","⽜奶","⾖奶","果汁","果味汽⽔","苏打⽔","运动饮料","酸奶","酒"}; printf("|-------------------------------------|\n");printf("| 今⽇宜饮:%s,%s\n",drinks[randNum%14],drinks[randNum1%14]);/*⼥神亲近指数*/int ambiguous = randNum%10;printf("|-------------------------------------|\n");if(10==ambiguous)printf("| 亲近指数为10,上吧,骚年!\n");elseprintf("| ⼥神亲近指数:%d \n",ambiguous);printf("|-------------------------------------|\n");return 0;}运⾏效果如下图所⽰:希望本⽂所述对⼤家的C语⾔程序设计有所帮助。

基于java的日历接口调用代码实例

基于java的日历接口调用代码实例

基于JAVA的日历接口调用代码实例代码描述:基于JA V A的日历接口调用代码实例代码平台:聚合数据import;import;import;import;import;import;import;import;import;import;import;import;/***万年历调用示例代码-聚合数据*在线接口文档:/177**/public class JuheDemo {public static final String DEF_CHATSET = "UTF-8";public static final int DEF_CONN_TIMEOUT = 30000;public static final int DEF_READ_TIMEOUT = 30000;public static String userAgent = "Mozilla/5.0 (Windows NT 6.1) Appl eWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36";//配置您申请的KEYpublic static final String APPKEY ="*************************";//1.获取当天的详细信息public static void getRequest1(){String result =null;String url ="/day";//请求接口地址Map params = new HashMap();//请求参数params.put("key",APPKEY);//您申请的appKeyparams.put("date","");//指定日期,格式为YYYY-MM-DD,如月份和日期小于10,则取个位,如:2012-1-1try{result =net(url, params, "GET");JSONObject object = JSONObject.fromObject(result);if(object.getInt("error_code")==0){"result"));}else{"error_code")+":"+object.get("reason"));}} catch(Exception e) {e.printStackTrace();}}//2.获取当月近期假期public static void getRequest2(){String result =null;String url ="/month";//请求接口地址Map params = new HashMap();//请求参数params.put("key",APPKEY);//您申请的appKeyparams.put("year-month","");//指定月份,格式为YYYY-MM,如月份和日期小于10,则取个位,如:2012-1try{result =net(url, params, "GET");JSONObject object = JSONObject.fromObject(result);if(object.getInt("error_code")==0){"result"));}else{"error_code")+":"+object.get("reason"));}} catch(Exception e) {e.printStackTrace();}}//3.获取当年的假期列表public static void getRequest3(){String result =null;String url ="/year";//请求接口地址Map params = new HashMap();//请求参数params.put("key",APPKEY);//您申请的appKeyparams.put("year","");//指定年份,格式为YYYY,如:2015 try{result =net(url, params, "GET");JSONObject object = JSONObject.fromObject(result);if(object.getInt("error_code")==0){"result"));}else{"error_code")+":"+object.get("reason"));}} catch(Exception e) {e.printStackTrace();}}public static void main(String[] args) {}/**** @param strUrl 请求地址* @param params 请求参数* @param method 请求方法* @return 网络请求字符串* @throws Exception*/public static String net(String strUrl, Map params,String method) th rows Exception {HttpURLConnection conn = null;BufferedReader reader = null;String rs = null;try{StringBuffer sb = new StringBuffer();if(method==null|| method.equals("GET")){strUrl = strUrl+"?"+urlencode(params);}URL url = new URL(strUrl);conn = (HttpURLConnection) url.openConnection();if(method==null|| method.equals("GET")){conn.setRequestMethod("GET");}else{conn.setRequestMethod("POST");conn.setDoOutput(true);}conn.setRequestProperty("User-agent", userAgent);conn.setUseCaches(false);conn.setConnectTimeout(DEF_CONN_TIMEOUT);conn.setReadTimeout(DEF_READ_TIMEOUT);conn.setInstanceFollowRedirects(false);conn.connect();if(params!= null&& method.equals("POST")) {try{DataOutputStream out = new DataOutputStream(conn.get OutputStream());out.writeBytes(urlencode(params));} catch(Exception e) {// TODO: handle exception}}InputStream is = conn.getInputStream();reader = new BufferedReader(new InputStreamReader(is, DEF_CH ATSET));String strRead = null;while((strRead = reader.readLine()) != null) {sb.append(strRead);}rs = sb.toString();} catch(IOException e) {e.printStackTrace();} finally{if(reader != null) {reader.close();}if(conn != null) {conn.disconnect();}}return rs;}//将map型转为请求参数型public static String urlencode(Map<String,Object>data) {StringBuilder sb = new StringBuilder();for(Map.Entry i : data.entrySet()) {try{sb.append(i.getKey()).append("=").append(URLEncoder.enc ode(i.getValue()+"","UTF-8")).append("&");} catch(UnsupportedEncodingException e) {e.printStackTrace();}}return sb.toString();}}。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

老黄历sdk接口实现及代码示例
老黄历sdk提供老黄历查询,黄历每日吉凶宜忌查询。

接口名称:老黄历sdk
接口平台:聚合数据
接口地址:/laohuangli/d
支持格式:JSON/XML
请求方式:HTTP GET/POST
请求示例:/laohuangli/d?date=2014-09-11&key=您申请的KEY 老黄历日历sdk接口JSON返回示例:
{
"reason": "successed",
"result": {
"id": "1657",
"yangli": "2014-09-11",
"yinli": "甲午(马)年八月十八",
"wuxing": "井泉水建执位",
"chongsha": "冲兔(己卯)煞东",
"baiji": "乙不栽植千株不长酉不宴客醉坐颠狂",
"jishen": "官日六仪益後月德合除神玉堂鸣犬",
"yi": "祭祀出行扫舍馀事勿取",
"xiongshen": "月建小时土府月刑厌对招摇五离",
"ji": "诸事不宜"
},
"error_code": 0
}
老黄历时辰sdk接口JSON返回示例:
{
"reason": "successed",
"result": [
{
"yangli": "2014-09-11",
"hours": "1-3",
"des": " 修造安葬求财见贵嫁娶进人口移徙",
"yi": "赴任出行",
"ji": "冲猴煞北时冲甲申地兵三合长生司命"
},
{
"yangli": "2014-09-11",
"hours": "3-5",
"des": " 祈福求嗣订婚嫁娶出行求财开市交易安床作灶祭祀",
"yi": "修造动土",
"ji": "冲猪煞东时冲丁亥路空日禄明堂"
}, {
"yangli": "2014-09-11",
"hours": "5-7",
"des": " 赴任修造移徙出行词讼祈福求嗣",
"yi": "求财见贵祭祀酬神",
"ji": "冲狗煞南时冲丙戍日破"
},
{
"yangli": "2014-09-11",
"hours": "7-9",
"des": " 赴任出行修造",
"yi": "冲马煞南时冲壬午天牢六戊天官福星",
"ji": "求财见贵祭祀酬神"
},
{
"yangli": "2014-09-11",
"hours": "9-11",
"des": " 赴任修造移徙出行词讼祈福求嗣",
"yi": "冲羊煞东时冲癸未日刑元武太阴国印",
"ji": "祭祀祈福合脊嫁娶安葬"
},
{
"yangli": "2014-09-11",
"hours": "11-13",
"des": " 冲鼠煞北时冲戊子三合大进帝旺贪狼",
"yi": "祈福求嗣订婚嫁娶出行求财开市交易安床赴任", "ji": "-"
},
{
"yangli": "2014-09-11",
"hours": "13-15",
"des": " 冲牛煞西时冲己丑日刑朱雀右弼",
"yi": "见贵求财嫁娶进人口移徙安葬",
"ji": "赴任出行朱雀须用凤凰符制否则诸事不宜"
},
{
"yangli": "2014-09-11",
"hours": "15-17",
"des": " 冲虎煞南时冲庚寅天兵喜神金匮左辅",
"yi": "祈福求嗣订婚嫁娶出行求财开市交易安床赴任见贵", "ji": "上梁盖屋入殓"
},
{
"yangli": "2014-09-11",
"hours": "17-19",
"des": " 冲兔煞东时冲辛卯狗食天赦贵人宝光",
"yi": "修造入宅安葬出行求财见贵订婚嫁娶",
"ji": "祭祀祈福斋醮酬神"
},
{
"yangli": "2014-09-11",
"hours": "19-21",
"des": " 冲龙煞北时冲壬辰日建六戊白虎武曲", "yi": "祭祀斋醮订婚嫁娶出行安葬",
"ji": "造船乘船祈福求嗣白虎须用麒麟符制否则诸事不宜"
},
{
"yangli": "2014-09-11",
"hours": "21-23",
"des": " 冲蛇煞西时冲癸已大退玉堂贵人少微",
"yi": "盖屋移徙安床入宅开市开仓祭祀祈福酬神出行求财见贵订婚嫁娶",
"ji": "开光修造安葬"
},
{
"yangli": "2014-09-11",
"hours": "23-1",
"des": " 祭祀祈福斋醮开光赴任出行",
"yi": "求财见贵订婚嫁娶入宅开市安葬修造盖屋移徙作灶安床",
"ji": "冲鸡煞西时冲乙酉勾陈天地"
}
],
"error_code": 0
}。

相关文档
最新文档