Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1.  
  2. import java.util.Date;
  3. import java.text.DateFormat;
  4. import java.text.ParseException;
  5. import java.text.SimpleDateFormat;
  6. import java.util.Calendar;
  7. import java.util.Date;
  8.  
  9.  
  10. public class App {
  11.  
  12. public static Date setDate(String dateStr, String format) {
  13. Date date = null;
  14. try {
  15. DateFormat dateFormat = new SimpleDateFormat(format);
  16. date = dateFormat.parse(dateStr);
  17. } catch (ParseException ex) {
  18. System.out.println("Exception during parse");
  19. }
  20.  
  21. return date;
  22. }
  23.  
  24. public static void main(String[] args) {
  25. Kot ratly = new Kot("Ratly");
  26. ratly.ileWazy(2);
  27. ratly.wlasciciel("Adam");
  28. Date date = setDate("1971/12/23 23:20:13", "yyyy/MM/dd HH:mm:ss");
  29. System.out.println("Kot urodzil sie: " + date);
  30.  
  31. }
  32. }
  33.  
  34.  
  35. public class Kot {
  36. String imie;
  37.  
  38. public Kot(String imie) {
  39. this.imie = imie;
  40. }
  41.  
  42. public void Przedstaw_kota() {
  43. System.out.println("Kot nazywa sie " + imie);
  44.  
  45. }
  46.  
  47. public void ileWazy(int waga) {
  48. System.out.println(imie + " waży " + waga + " kg");
  49.  
  50. }
  51.  
  52. public void wlasciciel(String opiekun) {
  53. System.out.println("Opiekuje sie nim " + opiekun);
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement