1. 灝忕▼搴忓紑鍙戜腑 new Date 璺ㄥ鉤鍙板吋瀹規ч棶棰樺備綍瑙e喅錛
鍦ㄧ炴佺煡灝忕▼搴忓紑鍙戜腑錛屼嬌鐢 new Date() 鏂規硶涓嶄細鍑虹幇鍏煎規ч棶棰樸傛父娑堜絾鏄錛屽傛灉鎮ㄤ嬌鐢 new Date(datetimeformatstring)錛屽彲鑳戒細鍑虹幇嫻忚堝櫒鍏煎規ч棶棰橈紝鍥犱負 datetimeformatstring 涓鐨勬煇浜涙牸寮忔祻瑙堝櫒涓嶅吋瀹廣
涓轟簡瑙e喅娓g珫榪欎釜闂棰橈紝鎮ㄥ彲浠ヤ嬌鐢ㄤ竴浜涚涓夋柟搴擄紝渚嬪 moment.js銆乨ate-fns 絳夌瓑銆傝繖浜涘簱鍙浠ュ府鍔╂偍澶勭悊鏃ユ湡鍜屾椂闂存牸寮忥紝騫舵彁渚涙洿濂界殑璺ㄥ鉤鍙板吋瀹規 銆
2. java鑾峰彇褰撳墠鏃墮棿鍔犲崐灝忔椂涔嬪悗鐨勬椂闂
涓銆佹ラゅ備笅錛
long currentTime = System.currentTimeMillis() + 30 * 60 * 1000銆
Date date = new Date(currentTime)銆
DateFormat df = new SimpleDateFormat(yyyy-MM-dd HH:mm:ss)銆係tring nowTime=銆俷owTime= df.format(date)銆係ystem.out.println(nowTime)銆
浜屻佸垎鏋愶細
1銆佽幏鍙栧綋鍓嶆椂闂達紝鑾峰彇鍒扮殑鏃墮棿綾誨瀷鏄痩ong綾誨瀷鐨勶紝鍗曚綅鏄姣縐
2銆佸湪榪欎釜鍩虹涓婂姞涓30鍒嗛挓錛歝urrentTime +=30*60*1000錛
3銆佹牸寮忓寲鏃墮棿錛岃幏鍙栧埌鐨勫氨鏄褰撳墠鏃墮棿鍗婁釜灝忔椂涔嬪悗鐨勬椂闂碊ate date=new Date(currentTime);
4銆佸緩絝嬫椂闂存牸寮忓寲瀵硅薄錛
SimpleDateFormat dateFormat = new SimpleDateFormat(yyyy-MM-dd HH:mm:ss)銆傛棶鎷︾
JDK錛圝ava Development Kit錛夌О涓篔ava寮鍙戝寘鎴朖ava寮鍙戝伐鍏鳳紝鏄涓涓緙栧啓Java鐨勬媶鍏咥pplet灝忕▼搴忓拰搴旂敤紼嬪簭鐨勭▼搴忓紑鍙戠幆澧冦侸DK鏄鏁翠釜Java鐨勬牳蹇冿紝鍖呮嫭浜咼ava榪愯岀幆澧冿紙Java Runtime Envirnment錛夛紝涓浜汮ava宸ュ叿鍜孞ava鐨勬牳蹇冪被搴擄紙Java API錛夈
涓嶈轟粈涔圝ava搴旂敤鏈嶅姟鍣ㄥ疄璐ㄩ兘鏄鍐呯疆浜嗘煇涓鐗堟湰鐨凧DK銆備富嫻佺殑JDK鏄瘲un鍏鍙稿彂甯冪殑JDK錛岄櫎浜哠un涔嬪栵紝榪樻湁寰堝氬叕鍙稿拰緇勭粐閮藉紑鍙戜簡琛¢ⅳ鑷宸辯殑JDK錛屼緥濡傦紝IBM鍏鍙稿紑鍙戠殑JDK錛孊EA鍏鍙哥殑Jrocket錛岃繕鏈塆NU緇勭粐寮鍙戠殑JDK
鍙﹀栵紝鍙浠ユ妸Java API綾誨簱涓鐨凧ava SE API瀛愰泦鍜孞ava鉶氭嫙鏈鴻繖涓ら儴鍒嗙粺縐頒負JRE錛圝AVA Runtime Environment錛夛紝JRE鏄鏀鎸丣ava紼嬪簭榪愯岀殑鏍囧噯鐜澧冦
3. 甯蹇欒В閲婁竴涓狫ava灝忕▼搴忥紙縐掕〃錛
package com.sofmit.tool;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;import java.util.Date;
import java.text.SimpleDateFormat;
public class StopWatch extends JFrame {
JButton btnStart, btnStop;
JLabel label; Timer timer;
public StopWatch() {
label = new JLabel("鏁板拰00:00:00.000");
btnStart = new JButton("start");
btnStop = new JButton("stop");
final int delay = 100;
final Date startTime = new Date();
final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.S");
final Action taskPerformer = new AbstractAction() {
public void actionPerformed(ActionEvent evt)
{ //鏄劇ず鏃墮棿
Date d = new Date(System.currentTimeMillis() - startTime.getTime() - 28800000); label.setText(sdf.format(d)); label.repaint();
}
};
btnStart.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt) {
startTime.setTime(new Date().getTime());
timer = new Timer(delay, taskPerformer); timer.start(); } });
btnStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (timer != null && timer.isRunning())
timer.stop();
} });
Container c = getContentPane();
c.add(label, BorderLayout.NORTH);
c.add(btnStart, BorderLayout.CENTER);
c.add(btnStop, BorderLayout.SOUTH); }
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() { createAndShowGUI(); } }); }
private static void createAndShowGUI() { StopWatch window = new StopWatch(); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.pack(); window.setVisible(true); }}
浣犱笅杞戒釜java鏂囨。錛屼腑鏂囩増鍚鍥扮洴鐨勶紝鎴栬呭厛鐪嬬湅瀛欓懌鐨刯ava鏃犻毦浜嬶紝榪欐槸緇欏昂鎵掍綘鏈濂界殑鎬濊礬錛
4. 小程序 在前端怎麼格式化後台返回的日期數據
var str="2017-11-17Tsdfsdfsdf";
str=str.replace(/(.*)T.*$/,"$1");