JAVA日期查询:季度月份星期等时间信息
Posted fitzroy343
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JAVA日期查询:季度月份星期等时间信息相关的知识,希望对你有一定的参考价值。
import java.util.Calendar; public class Date { Calendar calendar = null; public void test(){ calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int season; if( month>1 && month<5){ season = 1; } else if( month>4 && month<8 ){ season = 2; } else if( month>7 && month<11 ){ season = 3; } else{ season = 4; } int day = calendar.get(Calendar.DAY_OF_MONTH); int weekday = calendar.get(Calendar.DAY_OF_WEEK); int hour = calendar.get(Calendar.HOUR); int minute = calendar.get(Calendar.MINUTE); int second = calendar.get(Calendar.SECOND); System.out.println( year + "年" + month + "月" + day +"日"); System.out.println(hour + "时" + minute + "分" + second + "秒"); System.out.println(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second); } public static void main(String[] args){ Date d=new Date(); d.test();; } }
以上是关于JAVA日期查询:季度月份星期等时间信息的主要内容,如果未能解决你的问题,请参考以下文章
java 给月份3月和该月1日是星期二,求该月最后一个工作日的日期 如何实现