- // 处理月份
- if (yf.equals("1")) {
- sreturn = sreturn + s_yf;
- if (format.equals("1"))
- sreturn = sreturn + "月";
- else if (format.equals("2"))
- sreturn = sreturn + "-";
- else if (format.equals("3"))
- sreturn = sreturn + "/";
- else if (format.equals("5"))
- sreturn = sreturn + ".";
- }
- // 处理日期
- if (rq.equals("1")) {
- sreturn = sreturn + s_rq;
- if (format.equals("1"))
- sreturn = sreturn + "日";
- }
- }
- return sreturn;
- }
- public static String getNextMonthDay(String sdate, int m) {
- sdate = getOKDate(sdate);
- int year = Integer.parseInt(sdate.substring(0, 4));
- int month = Integer.parseInt(sdate.substring(5, 7));
- month = month + m;
- if (month < 0) {
- month = month + 12;
- year = year - 1;
- } else if (month > 12) {
- month = month - 12;
- year = year + 1;
- }
- String smonth = "";
- if (month < 10)
- smonth = "0" + month;
- else
- smonth = "" + month;
- return year + "-" + smonth + "-10";
- }
- public static String getOKDate(String sdate) {
- if (sdate == null || sdate.equals(""))
- return getStringDateShort();
- if (!VeStr.Isdate(sdate)) {
- sdate = getStringDateShort();
- }
- // 将“/”转换为“-”
- sdate = VeStr.Replace(sdate, "/", "-");
- // 如果只有8位长度,则要进行转换
- if (sdate.length() == 8)
- sdate = sdate.substring(0, 4) + "-" + sdate.substring(4, 6) + "-" + sdate.substring(6, 8);
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
- ParsePosition pos = new ParsePosition(0);
- Date strtodate = formatter.parse(sdate, pos);
- String dateString = formatter.format(strtodate);
- return dateString;
- }
- public static void main(String[] args) throws Exception {
- try {
- //System.out.print(Integer.valueOf(getTwoDay("2006-11-03 12:22:10", "2006-11-02 11:22:09")));
- } catch (Exception e) {
- throw new Exception();
- }
- //System.out.println("sss");
- }
Java时间转换(五)
精选 转载上一篇:Java时间转换(四)
下一篇:Struts2用户输入验证(1)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java 时间转换注解 java 时间转换为时间戳
java中各种date格式的转化
java 时间格式 整除 -
java时间搓在线转换 java时间转换成时间戳
java时间搓在线转换 java时间转换成时间戳
java 时间戳 System