/** * 获取字符串的长度,如果有中文,则每个中文字符计为2位 * * @param value * 指定的字符串 * * @return 字符串的长度 */ public static int length(String value) { int valueLength = 0; String chinese = "[\u0391-\uFFE5]"; /* 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1 */ for (int i = 0; i < val
获取一天前的时间 Date date = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.DATE, -1); date = calendar.getTime();
/* * 获取时间字符串*/public String getCurrentTime() { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); Date date = new Date(); return sdf.format(date); } public String getFutureTime(int changeDay) { Calendar date = Calendar.getInstance();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar c = Calendar.getInstance(); //过去七天 c.setTime(new Date()); c.add(Calendar.DATE, - 7); Date d = c.getTime(); String day = format.format(d); System.out.println("过去
java 获取日期的几天前,几个月前和几年前. package bys.utils; import java.util.Date; /** * Created by toutou on 2015/3/23. */ public class DateHelper { public static final long ONE_MINUTE = 60000L; public static final long ONE_HOUR = 3600000L; public static final long
mysql方法来源于:http://www.cnblogs.com/jjcc/p/5896588.html ###在网上看到一篇,非常赞的方法### 比如说要获取班级的前3名,mysql就可以用GROUP_CONCAT + GROUP BY + substring_index实现. 考试表 DROP TABLE IF EXISTS `test`;CREATE TABLE `test` (`id` int(11) DEFAULT NULL,`name` varchar(20) DEFAULT N