import java.text.SimpleDateFormat;
import java.util.Date; public void testString2Date() {
String startDate = "2017-08-15";
String endDate = "2017-08-15";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
int startDay = 0;
int endDay = 0; try {
Date dateStart = format.parse(startDate);
Date datEnd = format.parse(endDate); startDay = (int) (dateStart.getTime() / 1000);
endDay = (int) (datEnd.getTime() / 1000);
} catch (Exception e) {
e.printStackTrace();
}
System.err.println(startDay);
System.err.println(endDay);
}

java String时间转为时间戳的更多相关文章

  1. 中国标准时间、‘yyyy-MM-dd’格式时间转为时间戳

    中国标准时间转为时间戳 let _time="Tue Mar 20 2018 00:00:00 GMT+0800 (中国标准时间)"; console.log(Date.parse ...

  2. java中时间与时间戳的相互转换

    package com.test.one; import java.text.ParseException; import java.text.SimpleDateFormat; import jav ...

  3. java Date时间的各种转换方式和Mysql存时间类型字段的分析

    一:各种Date之间的转换方法 public class TimeTest { public static void main(String[] args) { Date date = new Dat ...

  4. jQuery添加添加时间与时间戳相互转换组件

    时间与时间戳的格式相互转换(转换主要兼容ie8,ie8不支持new Date()) (function($) { $.extend({ myTime: { CurTime: function () { ...

  5. JS时间转时间戳,时间戳转时间。时间显示模式。

    函数内容 // 时间转为时间戳 function date2timestamp(datetime) { var timestamp = new Date(Date.parse(datetime)); ...

  6. iOS 本地时间、UTC时间、时间戳等操作、获取当前年月日

    //获得当前时间并且转为字符串 - (NSString *)dateTransformToTimeString { NSDate *currentDate = [NSDate date];//获得当前 ...

  7. utc时间、本地时间及时间戳转化

    1.时间戳的概念 时间戳的定义请看百科unix时间戳,需要注意的时间戳为当前时刻减去UTC时间(1970.1.1)零点时刻的秒数差,与当前系统所处的时区无关,同一时刻不管在任何时区下得到的时间戳都是一 ...

  8. JS时间和时间戳的转换

    时间转为时间戳 timeToTimestamp(time){ let timestamp = Date.parse(time) return timestamp; } 时间戳转为本地时间 timest ...

  9. Java 日期时间 Date类型,long类型,String类型表现形式的转换

    Java 日期时间 Date类型,long类型,String类型表现形式的转换 1.java.util.Date类型转换成long类型 java.util.Date dt = new Date(); ...

随机推荐

  1. nopCommerce 3.9 大波浪系列 之 网页加载Widgets插件原理

    一.插件简介 插件用于扩展nopCommerce的功能.nopCommerce有几种类型的插件如:支付.税率.配送方式.小部件等(接口如下图),更多插件可以访问nopCommerce官网. 我们看下后 ...

  2. (转)Linux开机启动(bootstrap)

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 计算机开机是一个神秘的过程.我们只是按了开机键,就看到屏幕上的进度条或者一行行的输 ...

  3. [js] 实现接口

    摘要 js 语言并没有interface implement 关键字,如果要做到和后端语言类似的接口,一般会需要模拟实现. 在oo 编程中, 接口可以让架构师规定好模块必须要实现的方法, 尽量解耦模块 ...

  4. 【PHP】 安装参数

    1. 配置参数 './configure' '--prefix=/usr/local/php5.2' '--with-apxs2=/usr/sbin/apxs' '--with-mysql=/usr/ ...

  5. C——Network Saboteur (POJ2531)

    题目: A university network is composed of N computers. System administrators gathered information on t ...

  6. Python使用openpyxl读写excel文件

    Python使用openpyxl读写excel文件 这是一个第三方库,可以处理xlsx格式的Excel文件.pip install openpyxl安装.如果使用Aanconda,应该自带了. 读取E ...

  7. 15. leetcode 349. Intersection of Two Arrays

    Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1 ...

  8. vue指令v-for示例解析

    1.遍历数组 <div id="app"> <p v-for="item in items">my name is {{item}}&l ...

  9. IIS下防止mdb数据库被下载的实现方法

    第一种方法:要求网站管理人员具体asp编程经验.因为现在的销售虚拟主机的系统,已经为用户建立了一个database目录,跟web目录同一个级别,用户访问的是web中的文件,而无法访问database目 ...

  10. [原创] Python3.6+request+beautiful 半次元Top100 爬虫实战,将小姐姐的cos美图获得

    1 技术栈 Python3.6 Python的版本 request 得到网页html.jpg等资源的lib beautifulsoup 解析html的利器 html5lib 指定beautifulso ...