当前位置: 首页>>代码示例>>Java>>正文


Java Date.toString方法代码示例

本文整理汇总了Java中java.util.Date.toString方法的典型用法代码示例。如果您正苦于以下问题:Java Date.toString方法的具体用法?Java Date.toString怎么用?Java Date.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Date的用法示例。


在下文中一共展示了Date.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: backup

import java.util.Date; //导入方法依赖的package包/类
public void backup(String name, String path,String indexName) {
    if(storageProviderPath!=null){
        try{
        Socket socket=new Socket(storageProviderPath, storageProviderPort);
        PrintWriter writer=new PrintWriter(socket.getOutputStream(), true);
        ObjectOutputStream serializableOutputStream=new ObjectOutputStream(socket.getOutputStream());
        Date d=new Date();
        String timestamp=d.toString();
        writer.write("put:"+indexName);
        serializableOutputStream.writeObject(this);
        }catch(UnknownHostException uhe){
            uhe.printStackTrace();
        }
    }
    else{
        try {
        FileOutputStream fs = new FileOutputStream(path + "/" + name + ".ser");
        ObjectOutputStream out = new ObjectOutputStream(fs);
        out.writeObject(this);
        out.close();
        fs.close();
        } catch (IOException e) {
        //TODO: handle exception
        }
    }
}
 
开发者ID:EventHorizon27,项目名称:dataset-lib,代码行数:27,代码来源:StringIndex.java

示例2: formatDate

import java.util.Date; //导入方法依赖的package包/类
/**
 * Convert a Date to a timestamp String.
 * 
 * @param d a Date to format as a timestamp String.
 * @return a String representation of the current time.
 */
protected String formatDate(Date d) {
  try {
    synchronized (timeFormatter) {
      // Need sync: see bug 21858
      return timeFormatter.format(d);
    }
  } catch (Exception e1) {
    // Fix bug 21857
    try {
      return d.toString();
    } catch (Exception e2) {
      try {
        return Long.toString(d.getTime());
      } catch (Exception e3) {
        return "timestampFormatFailed";
      }
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:26,代码来源:LogWriterImpl.java

示例3: getStyledText

import java.util.Date; //导入方法依赖的package包/类
/**
 * This returns the label styled text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Object getStyledText ( Object object )
{
    Date labelValue = ( (ChangeEntry)object ).getDate ();
    String label = labelValue == null ? null : labelValue.toString ();
    StyledString styledLabel = new StyledString ();
    if ( label == null || label.length () == 0 )
    {
        styledLabel.append ( getString ( "_UI_ChangeEntry_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$
    }
    else
    {
        styledLabel.append ( getString ( "_UI_ChangeEntry_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$
    }
    return styledLabel;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:23,代码来源:ChangeEntryItemProvider.java

示例4: localTime

import java.util.Date; //导入方法依赖的package包/类
/**
 * <p>Convert a CVS date string into local time.</p>
 *
 * @param cvsDate The CVS date string.
 *
 * @return The date, converted to local time and reformatted.
 */
public String localTime (String cvsDate) {
  // A cvsDate has the following form "$Date: 2016/12/14 $"
  if (!cvsDate.startsWith("$Date: ")) {
    return cvsDate;
  }

  String yrS = cvsDate.substring(7,11);
  String moS = cvsDate.substring(12,14);
  String daS = cvsDate.substring(15,17);
  String hrS = cvsDate.substring(18,20);
  String miS = cvsDate.substring(21,23);
  String seS = cvsDate.substring(24,26);

  TimeZone tz = TimeZone.getTimeZone("GMT+0");
  GregorianCalendar gmtCal = new GregorianCalendar(tz);

  try {
    gmtCal.set(Integer.parseInt(yrS),
 Integer.parseInt(moS)-1,
 Integer.parseInt(daS),
 Integer.parseInt(hrS),
 Integer.parseInt(miS),
 Integer.parseInt(seS));
  } catch (NumberFormatException e) {
    // nop
  }

  Date d = gmtCal.getTime();

  return d.toString();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:39,代码来源:CVS.java

示例5: dateToString

import java.util.Date; //导入方法依赖的package包/类
/**
 * Converts the input to a string with special missing value handling
 */
private String dateToString(Date input) {
	if (input == null) {
		return null;
	} else {
		return input.toString();
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:11,代码来源:Evaluation.java

示例6: ReconocedorMensaje

import java.util.Date; //导入方法依赖的package包/类
public void ReconocedorMensaje(JTextArea TextAreaActual) {
    Palabra = GPalabra.getGst();
    if (!"".equals(Palabra)) {
        int answer = JOptionPane.showConfirmDialog(jd_User, "¿Quisiste decir " + Palabra + "?");
        if (answer == JOptionPane.YES_OPTION && Palabra.equals("send")) {
            String Mensaje = TextAreaActual.getText();
            Date FechaActual = new Date();
            String Destinatario = ((Contacto) cb_Recipients_Inbox.getSelectedItem()).getName() + " " + ((Contacto) cb_Recipients_Inbox.getSelectedItem()).getPhone();

            Mensaje NuevoMensaje = new Mensaje(FechaActual.toString(), Mensaje, Destinatario, UsuarioIngresado.getUserName(), true);
            ListaMensajes.add(NuevoMensaje);
            InsertarMensajeEnDB(FechaActual.toString(), Mensaje, Destinatario, UsuarioIngresado.getUserName());

            TextAreaActual.setText("");
            LlenarInbox();

            ListaBitacoras.add(new Bitacora(FechaBitacora.toString(), "Envio un mensaje", UsuarioIngresado.getUserName()));
            InsertarBitacoraEnDB(FechaBitacora.toString(), "Envio un mensaje", UsuarioIngresado.getUserName());
            LlenarBitacora();

            JOptionPane.showMessageDialog(jd_User, "Mensaje enviado exitosamente", "OPERACION EXITOSA", JOptionPane.INFORMATION_MESSAGE);
            Palabra = "";
            PalabraAnterior = "";
            GPalabra.setGst("");
        } else {
            Palabra = "";
            PalabraAnterior = "";
            GPalabra.setGst("");
        }
    }
}
 
开发者ID:alexycruz1,项目名称:LP_Proyecto,代码行数:32,代码来源:Principal.java

示例7: currentTime

import java.util.Date; //导入方法依赖的package包/类
@PostMapping("current_time")
public TimeResponse currentTime(@RequestBody TimeRequest timeRequest) {
    String name = timeRequest.getName();
    Date date = new Date();
    logger.info("get request : {}", timeRequest.getName());
    return new TimeResponse(name, date.toString(), date.getTime());
}
 
开发者ID:wyp0596,项目名称:elegant-springboot,代码行数:8,代码来源:TimeProvider.java

示例8: null2Blank

import java.util.Date; //导入方法依赖的package包/类
/**
 *null 处理
 *@param d 要进行转换的日期对像
 *@return 如果d为null值,返回空串"",否则返回d.toString()
 */

public static String null2Blank(Date d) {
    if (d == null)
        return "";
    else
        return d.toString();
}
 
开发者ID:LuJiangLin,项目名称:TestDemo1-github,代码行数:13,代码来源:CTool.java

示例9: isValidDateRange

import java.util.Date; //导入方法依赖的package包/类
/**
 * Checks the date range given with the input parameters.
 * 
 * @param fromDate
 *            the value validation is being performed on.
 * @param toDate
 *            the value validation is being performed on.
 * @throws ValidationException
 */
public static void isValidDateRange(Date fromDate, Date toDate)
        throws ValidationException {
    if (fromDate.after(toDate)) {
        Object[] params = { "From: " + fromDate.toString(),
                "To: " + toDate.toString() };
        ValidationException vf = new ValidationException(
                ReasonEnum.INVALID_DATE_RANGE, null, params);
        logValidationFailure(vf);
        throw vf;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:21,代码来源:BLValidator.java

示例10: localTime

import java.util.Date; //导入方法依赖的package包/类
/**
 * <p>Convert a CVS date string into local time.</p>
 *
 * @param cvsDate The CVS date string.
 *
 * @return The date, converted to local time and reformatted.
 */
public static String localTime (String cvsDate) {
  // A cvsDate has the following form "$Date: 2016/12/14 $"
  if (!cvsDate.startsWith("$Date: ")) {
    return cvsDate;
  }

  String yrS = cvsDate.substring(7,11);
  String moS = cvsDate.substring(12,14);
  String daS = cvsDate.substring(15,17);
  String hrS = cvsDate.substring(18,20);
  String miS = cvsDate.substring(21,23);
  String seS = cvsDate.substring(24,26);

  TimeZone tz = TimeZone.getTimeZone("GMT+0");
  GregorianCalendar gmtCal = new GregorianCalendar(tz);

  try {
    gmtCal.set(Integer.parseInt(yrS),
 Integer.parseInt(moS)-1,
 Integer.parseInt(daS),
 Integer.parseInt(hrS),
 Integer.parseInt(miS),
 Integer.parseInt(seS));
  } catch (NumberFormatException e) {
    // nop
  }

  Date d = gmtCal.getTime();

  return d.toString();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:39,代码来源:CVS.java

示例11: buildLogMessage

import java.util.Date; //导入方法依赖的package包/类
protected String buildLogMessage(Level level, String tag, String message, long msTimestamp) {
  Date now = new Date(msTimestamp);
  return now.toString() + " " + "[" + level + "] " + tag + ": " + message;
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:5,代码来源:DefaultLogger.java

示例12: mirrors

import java.util.Date; //导入方法依赖的package包/类
private void mirrors() {
    boolean boo = true;
    byte b = 5;
    char c = 'c';
    short s = 512;
    int i = 10000;
    long l = Long.MAX_VALUE;
    float f = 12.12f;
    double d = 1e150;
    
    int[] iarr = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    double[][] darr = new double[][] { { 0.1, 0.2, 0.3 }, { 1.1, 1.2, 1.3 }, { 2.1, 2.2, 2.3 } };
    
    String str = "A String";
    Integer integer = new Integer(Integer.MIN_VALUE);
    
    Date date = new Date(1000000000l);
    date.toString(); // This is necessary to initialize the Date.cdate field and Gregorian$Date class.
    Color color = Color.RED;
    Point point = new Point(10, 10);
    File file = new File("/tmp/Foo.txt");
    URL url = createURL("http://netbeans.org");
    URL url2 = createPristineURL();
    
    Color[][] colors = new Color[][] { { Color.WHITE, Color.BLACK }, { Color.YELLOW, Color.GRAY } };
    
    List selfReferencedList = createSelfReferencedList();
    EventObject event = createObjectCircle();
    
    System.currentTimeMillis();             // LBREAKPOINT
    
    boolean newValues = (boo == false) && b == (byte) 255 && c == 'Z' &&
                         s == (short) -1024 && i == -1 && l == 123456789101112l &&
                         f == 2e-2f && d == -3e250 &&
                         Arrays.equals(iarr, new int[] { 9, 7, 5, 3, 1 }) &&
                         Arrays.deepEquals(darr, new double[][] { { 1e100, 2e200 }, { 1.1e100, 2.1e200 }, { 1.2e100, 2.2e200 }, { 1.3e100, 2.3e200 } }) &&
                         str.equals("An alternate sTRING") &&
                         integer.equals(-1048576) &&
                         date.equals(new Date(3333333333l)) &&
                         color.equals(Color.GREEN) &&
                         point.equals(new Point(-100, -100)) &&
                         file.equals(new File("/tmp/Test.java")) &&
                         url.equals(createURL("http://debugger.netbeans.org")) &&
                         url2 == null;
    
    System.currentTimeMillis();             // LBREAKPOINT
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:MirrorValuesApp.java

示例13: getManageExec

import java.util.Date; //导入方法依赖的package包/类
private ManageExec getManageExec(String server, String action, OutputStream out, boolean quiet) {
	// need to do a series of local checks eg known_hosts or expected
	// fingerprint
	if (servers.containsKey(server)) {
		ServerModel serverModel = servers.get(server);
		PasswordExec pass = new PasswordExec(server, this);

		if (!pass.init()) {
			return null;
		} else {
			String password = pass.getPassword();
			
			System.out.println("PASS: password in keychain for " + serverModel.getLabel());
			String audit = getScript(serverModel, action, quiet);
			
			if (action.equals("dryrun")) {
				try {
					Date now = new Date();
					PrintWriter wr = new PrintWriter(new FileOutputStream("./" + server + "_" + now.toString() + ".sh"));
					wr.write(audit);
					wr.flush();
					wr.close();
				} catch (FileNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return null;
			}

			if (password == null || password.equals("")) {
				System.out.println("FAIL: no password in keychain for " + serverModel.getLabel());
				return null;
			}
			
			ManageExec exec = new ManageExec(server, this, password, audit, out);
			return exec;
		}
	} else {
		System.out.println("No server " + server);
	}
	return null;
}
 
开发者ID:privacyint,项目名称:thornsec-core,代码行数:43,代码来源:NetworkModel.java

示例14: getMtimeString

import java.util.Date; //导入方法依赖的package包/类
public String  getMtimeString(){
  Date date= new Date(((long)mtime)*1000);
  return (date.toString());
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:5,代码来源:SftpATTRS.java

示例15: getAtimeString

import java.util.Date; //导入方法依赖的package包/类
public String  getAtimeString(){
  Date date= new Date(((long)atime)*1000L);
  return (date.toString());
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:5,代码来源:SftpATTRS.java


注:本文中的java.util.Date.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。